2013-07-09 27 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); 

檢查它,但它不是解決帶動畫的洞問題