0

这是代码:

$('.next').click(function(){
        $(window).stop(true,true).scrollTo('+=800px', 1000, { axis:'x' } );
 });
$('.prev').click(function(){
        $(window).stop(true,true).scrollTo('-=800px', 1000, { axis:'x' } );
 });

网站可以在这里预览:http ://www.allisonnavon.com/index.php?/projects/raw-rhythm/

当多次单击 » 时,它会将它们排入队列,即使使用stop(true,true)参数也是如此。有谁知道为什么?

4

1 回答 1

1

.stop()仅影响该元素的动画队列,而.animate()在这种情况下您可以(此处不需要scrollTo插件):

$('.next').click(function(){
  $("html, body").stop(true,true).animate({ scrollLeft: '+=800' }, 1000);
});
$('.prev').click(function(){
  $("html, body").stop(true,true).animate({ scrollLeft: '-=800' }, 1000);
});

这样,影响这些元素上的动画队列。.stop()

于 2010-10-12T18:46:30.613 回答