diff --git a/src/action-sheet/index.tsx b/src/action-sheet/index.tsx index d8d91dab9..4e967011d 100644 --- a/src/action-sheet/index.tsx +++ b/src/action-sheet/index.tsx @@ -30,7 +30,7 @@ export type ActionSheetProps = PopupMixinProps & { round: boolean; title?: string; actions?: ActionSheetItem[]; - duration: number; + duration: number | string; closeIcon: string; cancelText?: string; description?: string; diff --git a/src/popup/index.js b/src/popup/index.js index f9db81a2a..8808f59ce 100644 --- a/src/popup/index.js +++ b/src/popup/index.js @@ -49,14 +49,16 @@ export default createComponent({ } const { round, position, duration } = this; + const isCenter = position === 'center'; const transitionName = this.transition || - (position === 'center' ? 'van-fade' : `van-popup-slide-${position}`); + (isCenter ? 'van-fade' : `van-popup-slide-${position}`); const style = {}; if (isDef(duration)) { - style.transitionDuration = `${duration}s`; + const key = isCenter ? 'animationDuration' : 'transitionDuration'; + style[key] = `${duration}s`; } return ( diff --git a/src/popup/test/__snapshots__/index.spec.js.snap b/src/popup/test/__snapshots__/index.spec.js.snap index 8398b7e31..8552d5572 100644 --- a/src/popup/test/__snapshots__/index.spec.js.snap +++ b/src/popup/test/__snapshots__/index.spec.js.snap @@ -5,7 +5,9 @@ exports[`close-icon prop 1`] = ` `; -exports[`duration prop 1`] = `
`; +exports[`duration prop when position is center 1`] = ``; + +exports[`duration prop when position is top 1`] = ``; exports[`reset z-index 1`] = ``; diff --git a/src/popup/test/index.spec.js b/src/popup/test/index.spec.js index bd10a0eef..f570087a7 100644 --- a/src/popup/test/index.spec.js +++ b/src/popup/test/index.spec.js @@ -206,7 +206,7 @@ test('click event', () => { expect(wrapper.emitted('click')).toBeTruthy(); }); -test('duration prop', () => { +test('duration prop when position is center', () => { const wrapper = mount(Popup, { propsData: { value: true, @@ -217,6 +217,18 @@ test('duration prop', () => { expect(wrapper).toMatchSnapshot(); }); +test('duration prop when position is top', () => { + const wrapper = mount(Popup, { + propsData: { + value: true, + duration: 0.5, + position: 'top', + }, + }); + + expect(wrapper).toMatchSnapshot(); +}); + test('round prop', () => { const wrapper = mount(Popup, { propsData: {