[improvement] Popup: optimize overlay animation duration (#3610)

This commit is contained in:
neverland
2019-06-24 11:43:34 +08:00
committed by GitHub
parent d6ed8cfe55
commit 7d29ae8a2d
3 changed files with 20 additions and 10 deletions
+12 -3
View File
@@ -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<OverlayProps>
) {
const style = {
const style: { [key: string]: any } = {
zIndex: props.zIndex,
...props.customStyle
};
if (isDef(props.duration)) {
style.animationDuration = `${props.duration}s`;
}
return (
<transition name="van-fade">
<div
@@ -51,7 +56,11 @@ Overlay.props = {
zIndex: Number,
className: null as any,
visible: Boolean,
customStyle: Object
customStyle: Object,
duration: {
type: Number,
default: null
}
};
export default sfc<OverlayProps, OverlayEvents>(Overlay);