Javascript jQueryScrollTop加速
我有一个scrollTop的jquery脚本,并试图找出它启动后加速的原因。它开始缓慢,然后变得更快 有没有办法在开始时停止延迟,并使其在整个滚动中保持相同的速度Javascript jQueryScrollTop加速,javascript,jquery,scrolltop,Javascript,Jquery,Scrolltop,我有一个scrollTop的jquery脚本,并试图找出它启动后加速的原因。它开始缓慢,然后变得更快 有没有办法在开始时停止延迟,并使其在整个滚动中保持相同的速度 // When DOM is fully loaded jQuery(document).ready(function ($) { function scroll(speed) { $('.shooter-scroller').animate({ scrollTop: $('.shooter-scroller'
// When DOM is fully loaded
jQuery(document).ready(function ($) {
function scroll(speed) {
$('.shooter-scroller').animate({ scrollTop: $('.shooter-scroller').prop('scrollHeight') }, speed, function() {
$(this).animate({ scrollTop: 0 }, speed);
});
}
speed = 80000;
scroll(speed)
setInterval(function(){scroll(speed)}, speed * 2);
});
在下面拉小提琴:
JQuery设计为具有这种形式的滚动条。 您可以尝试:它也支持恒速滚动。jQuery的easing属性默认设置为
swing
。将easing属性更改为linear
将为您提供所需的恒定速度
下面是一个带有easing属性的代码示例
// When DOM is fully loaded
jQuery(document).ready(function ($) {
function scroll(speed) {
$('.shooter-scroller').animate({
scrollTop: $('.shooter-scroller').prop('scrollHeight'),
easing: 'linear'
}, {
duration: speed,
easing: 'linear', // <--- here
complete: function () {
$(this).animate({
scrollTop: 0
}, {
duration: speed,
easing: 'linear', // <--- here
complete: speed
});
}
});
}
speed = 8000;
scroll(speed)
setInterval(function () {
scroll(speed)
}, speed * 2);
});
//当DOM完全加载时
jQuery(文档).ready(函数($){
功能滚动(速度){
$('.shooter scroller')。设置动画({
scrollTop:$('.shooter scroller').prop('scrollHeight'),
放松:“线性”
}, {
持续时间:速度,
放松:'线性',//试试这个:$(这个)。动画({scrollTop:0,放松:'线性'},速度);
比我快30秒…我批准这个消息!太好了!再次感谢!