[英]why react-transition-group is not working?
I am trying to use animation when the state changes and elements mounts, tried the way mentioned in React Transition Group documentation but failed. 当状态改变和元素挂载时,我尝试使用动画,尝试了React Transition Group文档中提到的方法,但是失败了。
I have a UI something like this: 我有一个类似这样的用户界面:
The center circle item is an active item and changes when the user selects other items. 中心圆圈项目是活动项目,当用户选择其他项目时会更改。
I want fadeIn and fadeOut animation effects when the item changes. 当项目更改时,我需要fadeIn和fadeOut动画效果。
created the example of the code codesandbox link 创建了代码codeandbox链接的示例
a snippet of code: 一小段代码:
jsx: JSX:
<TransitionGroup>
{this.state.items.map((data, index) => (
<CSSTransition key={index} timeout={1000} classNames="item">
<div
className={"list " + (index === 2 ? " active" : "")}
key={index}
onClick={() => this.setItems(data)}
>
<span>{data}</span>
</div>
</CSSTransition>
))}
</TransitionGroup>
css: CSS:
.item-enter {
opacity: 0;
}
.item-enter-active {
opacity: 1;
transition: opacity 1000ms ease-in;
}
.item-exit {
opacity: 1;
}
.item-exit-active {
opacity: 0;
transition: opacity 1000ms ease-in;
}
It's look like you are simply reordering the element. 看起来您只是在重新排序元素。
try this https://popmotion.io/pose/examples/posegroup-reordering/ 试试这个https://popmotion.io/pose/examples/posegroup-reordering/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.