-
Notifications
You must be signed in to change notification settings - Fork 384
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
react-css-transition实战 #61
Labels
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
问题
继上回 #57 做了react动画的demo之后,我尝试将demo整合到项目当中,不过同样遇到了很多问题。
#1. 安装!
原先参考一些教程和做demo的时候引用react-css-transition的时候是这样的。
实际当中却不行。原因是因为在react v0.15版本开始,addons这些插件都会被单独出来。所以得单独安装使用。。
插件地址在这儿。https://www.npmjs.com/package/react-addons-css-transition-group
参考官方文档:https://facebook.github.io/react/docs/addons.html
#2. 由key值是否改变控制是否切换
比如说。
只有this.state.index发生变化的时候,才会触发动画,而不管里面嵌套了多少组件。
#3. DOM元素什么时候消失?
在最开始的demo中,DOM元素添加了example-leave类之后什么时候消失,其实是通过动画本身指定的。
也就是说,当动画结束之后,要离开的DOM元素才会从真实DOM中删除。
但是我在使用最新版本的ReactCSSTransitionGroup的时候却报了warning。
在这里,就最好在ReactCSSTransitionGroup中指定给元素添加了leave-active类之后多久删除DOM元素,而不是由动画间接决定。同样的道理,进入也需要做这样的处理。
代码大概如下:
参考资料:
https://www.alloyteam.com/2016/01/react-animation-practice/
The text was updated successfully, but these errors were encountered: