如何降低jquery滚动速度以避免动画闪烁
我目前正在使用以下代码,但我需要将其速度减慢,以避免动画闪烁。该网站发布于dotmobi如何降低jquery滚动速度以避免动画闪烁,jquery,scrollto,Jquery,Scrollto,我目前正在使用以下代码,但我需要将其速度减慢,以避免动画闪烁。该网站发布于dotmobi $('#nav a, #top-nav a, #bottom-nav a').click(function(e){ var my_offset = $(this.hash).offset().top; $('body').scrollTo(this.hash, {duration:'slow'}); //$('html, body').scrollTo(this.hash, th
$('#nav a, #top-nav a, #bottom-nav a').click(function(e){
var my_offset = $(this.hash).offset().top;
$('body').scrollTo(this.hash, {duration:'slow'});
//$('html, body').scrollTo(this.hash, this.hash);
return false;
});
试一试
不要说慢,而是以毫秒(1000=1秒)为单位输入值。 例如
如果您的浏览器闪烁,则表示您没有功能强大的浏览器或系统资源不足。而是使用hide()和show()而不是动画。如果要隐藏,请在一两秒钟后隐藏以避免闪烁。谢谢,动画闪烁只发生在iPad上。注意:如果您选择使用jQuery animate,请从Greensock()查看TweenMax(例如速度和功率,查看英特尔主页),速度会快得多!
$('html, body').animate({
scrollTop: my_offset
}, 2000); // 2000ms = 2s duration
$('#nav a, #top-nav a, #bottom-nav a').click(function(e){
var my_offset = $(this.hash).offset().top;
$('body').scrollTo(this.hash, {duration:'2000'});
//$('html, body').scrollTo(this.hash, this.hash);
return false;
});