我有一个类似的收藏列表:
class App extends Component {
constructor(props) {
super(props);
this.state = {
items: [
"https://images.unsplash.com/photo...",
"https://images.unsplash.com/photo...",
"https://images.unsplash.com/photo...",
"https://images.unsplash.com/photo...",
"https://images.unsplash.com/photo...",
"https://images.unsplash.com/photo...",
]
};
}
}
这些收藏品是全屏图像,我希望对其进行动画处理。问题是我试图为它们设置动画,而没有任何点击事件(更像是循环),并且我希望它可以无限期地动画。
这是我到目前为止所拥有的:
render() {
const items = this.state.items.map((item, i) => {
if (i === this.state.show) {
return (
<img src={item} alt="" className="bg" key={i}/>
)
} else {
return null
}
});
return (
<div className="App">
<div className="container">
<div className="arrow" onClick={this.next}><ArrowLeft/></div>
<div className="img-container">
<ReactCSSTransitionGroup
transitionName={this.state.slideDirection}
transitionEnterTimeout={0}
transitionLeaveTimeout={0}
>
{items}
</ReactCSSTransitionGroup>
</div>
<div className="arrow" onClick={this.prev}><ArrowRight/></div>
</div>
</div>
);
}