2013-07-09 30 views
1

请帮我纠正我的脚本:http://jsfiddle.net/b36cM/动画jQuery的破

   if(direction == -1){ 
        wrapperElements.children(':last').after($('#carousel > ul').children().slice(0, options.rotateBy).clone()); 

        shiftAction(); 

        wrapperElements.children().slice(0, options.rotateBy).remove(); 
       } 
       else{ 
        // wrapperElements.children(':first').after($('#carousel > ul').children().slice(carouselLength - options.rotateBy, carouselLength).clone()); 

        // shiftAction(); 

        // wrapperElements.children().slice(carouselLength - options.rotateBy, carouselLength).remove(); 
       }    
      } 

      function shiftAction(){ 
       console.log(offset); 

       wrapperElements.animate({ 
        'left': offset     
       }, options.speed, function(){ 
             running = false; 
            });     
      }    
     } 

#prev点击动画转移两个元素的左边。我只想顺利地滚动一个项目。

回答

0

注重的是shiftAction()和remove()异步运行时元素去除,从而动画没有完成,让你的动画跳第一个元素,你可以用

setTimeout(function() { 
     wrapperElements.children().slice(0, options.rotateBy).remove(); 
     },5000); 

检查它,但它不是解决带动画的洞问题