From 7d29ae8a2d0282692e9759b1811743dab1c1e134 Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 24 Jun 2019 11:43:34 +0800 Subject: [PATCH] [improvement] Popup: optimize overlay animation duration (#3610) --- .../test/__snapshots__/index.spec.js.snap | 10 +++++----- packages/mixins/popup/index.js | 5 +++-- packages/overlay/index.tsx | 15 ++++++++++++--- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/packages/dropdown-menu/test/__snapshots__/index.spec.js.snap b/packages/dropdown-menu/test/__snapshots__/index.spec.js.snap index a0c2a521b..35ac9efe9 100644 --- a/packages/dropdown-menu/test/__snapshots__/index.spec.js.snap +++ b/packages/dropdown-menu/test/__snapshots__/index.spec.js.snap @@ -37,7 +37,7 @@ exports[`close on click outside 1`] = `
B
-
+
-
+
-
+
-
+
`; @@ -182,7 +182,7 @@ exports[`show dropdown item 3`] = `
B
-
+
`; diff --git a/packages/mixins/popup/index.js b/packages/mixins/popup/index.js index fccf74476..5670ee408 100644 --- a/packages/mixins/popup/index.js +++ b/packages/mixins/popup/index.js @@ -73,8 +73,8 @@ export const PopupMixin = { } }, + /* istanbul ignore next */ activated() { - /* istanbul ignore next */ if (this.value) { this.open(); } @@ -88,8 +88,8 @@ export const PopupMixin = { } }, + /* istanbul ignore next */ deactivated() { - /* istanbul ignore next */ this.close(); }, @@ -171,6 +171,7 @@ export const PopupMixin = { if (this.overlay) { openOverlay(this, { zIndex: context.zIndex++, + duration: this.duration, className: this.overlayClass, customStyle: this.overlayStyle }); diff --git a/packages/overlay/index.tsx b/packages/overlay/index.tsx index 73c835492..a7f9b78ea 100644 --- a/packages/overlay/index.tsx +++ b/packages/overlay/index.tsx @@ -1,4 +1,4 @@ -import { use } from '../utils'; +import { use, isDef } from '../utils'; import { inherit } from '../utils/functional'; import { preventDefault } from '../utils/dom/event'; @@ -10,6 +10,7 @@ export type OverlayProps = { zIndex?: number; className?: any; visible?: boolean; + duration: number | null; customStyle?: object; }; @@ -29,11 +30,15 @@ function Overlay( slots: DefaultSlots, ctx: RenderContext ) { - const style = { + const style: { [key: string]: any } = { zIndex: props.zIndex, ...props.customStyle }; + if (isDef(props.duration)) { + style.animationDuration = `${props.duration}s`; + } + return (
(Overlay);