[new feature] Popup: add opened/closed event (#2650)

This commit is contained in:
neverland 2019-01-30 19:43:17 +08:00 committed by GitHub
parent 466bb3ce1e
commit 01c893abcb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 1 deletions

View File

@ -55,5 +55,7 @@ Use `position` prop to set popup display position
| Event | Description | Arguments |
|------|------|------|
| open | Triggered when open Popup | - |
| opened | Triggered when opened Popup | - |
| close | Triggered when close Popup | - |
| closed | Triggered when closed Popup | - |
| click-overlay | Triggered when click overlay | - |

View File

@ -25,10 +25,15 @@ export default sfc({
}
const { position } = this;
const emit = event => () => this.$emit(event);
const transitionName = this.transition || (position ? `van-popup-slide-${position}` : 'van-fade');
return (
<transition name={transitionName}>
<transition
name={transitionName}
onAfterEnter={emit('opened')}
onAfterLeave={emit('closed')}
>
<div vShow={this.value} class={bem({ [position]: position })}>
{this.$slots.default}
</div>

View File

@ -55,5 +55,7 @@ export default {
| 事件名 | 说明 | 参数 |
|------|------|------|
| open | 打开弹出层时触发 | - |
| opened | 打开弹出层且动画结束后触发 | - |
| close | 关闭弹出层时触发 | - |
| closed | 关闭弹出层且动画结束后触发 | - |
| click-overlay | 点击蒙层时触发 | - |