Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Popup 添加 transitionEnd 事件 #1345

Merged
merged 2 commits into from
Mar 10, 2019

Conversation

thoamsy
Copy link
Contributor

@thoamsy thoamsy commented Feb 26, 2019

动机

假设现在有一个需求,我们的 ListItem 具有触发 PopUp 的能力。有两种方式可以做到:

  1. ListItem 中声明 Popup,通过 wx:if 来做到性能优化。
  2. ListItem 的父组件,比如 List 中声明,通过在 ListItemtriggerEvent 来发生 PopUp 所需要的数据。

第二种方式目前常用的方式,因为如果直接用 wx:if 判断的话,关闭 Popup 时没有动画,导致整个过程很生硬。而现有的生命周期又不满足需求,所以通过在 transtion 后,将 wx:if 改为 false 就能拿到效果。

虽然我们可以继续使用第二种方式,但是它很容易让 List 变成一个非常庞大的组件。这里有一个 Popup,那里又有一个 Popup,不知不觉就变成了 PopUp 中转站。所以,通过添加这个事件,可以在一定程序上减少对 List 的依赖。更关注 ListItem 本身。

@rex-zsd
Copy link
Collaborator

rex-zsd commented Mar 8, 2019

有点没理解,你的需求是希望能够监听到popup实际关闭的事件吗?

@thoamsy
Copy link
Contributor Author

thoamsy commented Mar 9, 2019

嗯嗯是的。

@rex-zsd rex-zsd merged commit 806f51c into youzan:dev Mar 10, 2019
@rex-zsd
Copy link
Collaborator

rex-zsd commented Mar 10, 2019

👍 很棒,感谢贡献

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants