问题描述
在更新要转换的值时,在转换结束之前,当前转换会中断并重新开始,因为组件会重新渲染,这对我来说是可见的中断,是不希望的。
换句话说,我的目标是更改已应用的CSS,而不会触发可见的重启或重新渲染。
示例
//At first offset changes to:
offset = 100px
.myclass {
transform: translateX(offset);
transition: transform 1s linear;
}
// After 0.5 seconds (before the transition has ended) offset changes again:
offset = 250px
// Therefore,Now the .myclass object needs to move 250px - 100px = 150px to the
// right in 1 second (because thats the duration of the transition that is repeated)
实施
我已经分叉了Carousel(滑块)的实现,并通过监听按键(左箭头,右箭头)对其进行了修改。
如果按下两个键中的任意一个,则使用translateX()
显示上一个或下一个项目。
如果连续按住该键,则应该连续移动。但是,当前动画将停止,直到释放关键为止。
代码:(使用react app创建)
我的代码可以在以下位置找到:https://github.com/TkinterinShanghai/react-image-slideshow
原始存储库:https://github.com/Ihatetomatoes/react-image-slideshow
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)