我想使滑块顺滑地上下移动。该怎么办?
$(scroller).scroll(function(e){
e.preventDefault();
var that = $(e.target);
clearTimeout($.data(this, 'scrollTimer'));
$.data(this, 'scrollTimer', setTimeout(function() {
that.scrollTop(slide(that.scrollTop()));
}, 200));
})
function slide(s){
var currentIndex = Math.round(s/600);
return 600*currentIndex;
}
尝试.animate()函数后,所有操作都会崩溃... 此处的完整代码:https://codesandbox.io/embed/jovial-feather-cq1zd?fontsize=14