2014-10-06 92 views
0

我有一個滑動條,除了讓磁盤動畫到相應的幻燈片外,其他功能都非常完美。我想因爲我有幻燈片改變他們的無限循環的數量,它與碟片按鈕如何選擇它們混淆。如果有人有修復請分叉我的代碼。滑塊按鈕功能

http://codepen.io/Spiderian/pen/IKvah

這裏是有問題的代碼:

discs.click(function(e) 
{ 
    console.log(slideAnimating); 


    var btnIndex = discs.index(this); 


    if(!slideAnimating && btnIndex !== slideNumber) 
    { 

    timerFunction.pause(); 


    nextSlide = btnIndex; 


    changeSlide(); 
    } 
+0

(OT)你意識到這種壓痕,使靈魂充滿了痛苦? – 2014-10-06 18:47:54

回答

1

您的問題並不在discs.click但changeSlide()。

有了這個編輯它將工作:

function changeSlide() 
{ 

    slideAnimating = true; 

    console.log("slide out => " + slideNumber); 
    console.log("slide IN => " + nextSlide + "\n"); 

    currentDisk = nextSlide; // Edit #1 

    TweenMax.to(discs.eq(slideNumber), 1, {backgroundColor:"#ffffff", borderColor:"#f10000"}); 

    TweenMax.to(slides[slideNumber], duration, 
    { 
     left:"-100%", 
     onComplete:function() 
     { 

     slideAnimating = false; 

     timerFunction.restart(true); 

     if(wrapper.hasClass("mouse-over")) 
     { 
      timerFunction.pause(); 
     } 

     TweenMax.set(this.target, {left:"100%"}); 
     } 
    }); 

    TweenMax.fromTo(discs.eq(currentDisk), 1, {backgroundColor:"#ffffff", borderColor:"#f10000"}, {backgroundColor:"#f10000", borderColor:"#ffffff"}); 

    TweenMax.to(slides[nextSlide], duration, 
    { 
     left:"0%" 
    }); 

    if(nextSlide < totalSlides -1) 
    { 

    slideNumber = nextSlide; 

    nextSlide++; 
    } 
    else 
    { 

    slideNumber = nextSlide; 

    nextSlide = 0; 
    console.log("first slide!!"); 
    } 

}