沿相反方向移动的Div元素导致滚动到抖动

时间:2016-11-01 16:06:32

标签: javascript jquery scroll transform translate

我正在创建一个滚动效果,使每个图像在滚动时以相反的方向移动。我已经实现了这一点,但滚动变得越来越不平滑,越滚动越来越紧张。

我相信这是因为我经常从视口顶部获取每个图像(项目)的距离。有谁知道怎么解决这个问题?

     Question   0      1          2        3       4   5   6   7   8  
0        1     NaN  Never  Sometimes  Usually  Always NaN NaN NaN NaN   
1        2     NaN  Never  Sometimes  Usually  Always NaN NaN NaN NaN   
2        3     NaN  Never  Sometimes  Usually  Always NaN NaN NaN NaN   
3        4     NaN  Never  Sometimes  Usually  Always NaN NaN NaN NaN

小提琴已添加:https://jsfiddle.net/2bos5oqh/4/

1 个答案:

答案 0 :(得分:0)

动画是否有动画持续时间?如果是这样,可能在单个更新完成之前滚动事件多次触发。

尝试对该功能进行去抖动 https://davidwalsh.name/javascript-debounce-function