2011-02-14 32 views
2
/* ------------------------------------------------------------------------ 
    plugin-name:zxdSlider 
    Developped By: ZHAO Xudong -> http://html5beta.com 
    Version: 1.0 
    Copyright: Feel free to redistribute the script/modify it, as 
       long as you leave my infos at the top. 
------------------------------------------------------------------------ */ 
(function($){ 
     $.fn.zxdSlider = function() { 
       var zxdCaller = this.attr('id'); 
       var sliderUnit = $("#"+zxdCaller); 
       var sc = $("."+zxdCaller+"li"); 
       var queueName = zxdCaller+"Queue";//queue-name 
       var delayFlag = false; 
       var current = 0; //current is the slider index 
       var maxNo = -1; 
       sc.each(function(i){maxNo=i}); // check how many unit to slide 
       var shortDelay = 600; 
       var longDelay = 3000; 
       var fq = [ //this is the function loop.after it fires,it never ends 
         function(){sc.eq(current).show(shortDelay,af);}, 
         function(){setTimeout(af,shortDelay);},  
         function(){sc.eq(current).children("span").show(shortDelay,af)}, 
         function(){setTimeout(af,longDelay);},  
         function(){ 
           if (delayFlag==false){//if mouseover ,the current slider do not hide 
             sc.eq(current).children("span").hide(shortDelay/2,af); 
           } 
           else { 
             af(); 
           } 
         }, 
         function(){ 
           if (delayFlag==false){ //if mouseover ,the current slider do not hide 
             sc.eq(current).hide(shortDelay/2,af); 
           } 
           else { 
             af(); 
           } 
         }, 
         function(){ 
           if(delayFlag==false) { //if mouseover ,slider index stays the same. 
             current++; 
             af(); 
           } 
           else{ 
             af(); 
           } 
         }, 
         function(){// the last function fires the loop again 
           slider(); 
         } 
       ]; 
       var af = function(){//use dequeue to make the loop move forward 
         $(document).dequeue(queueName); 
       }; 
       $(".rightnav").click(function(){//click to see next slider 
         sc.eq(current).children("span").hide(shortDelay/2); 
         sc.eq(current).hide(shortDelay/2); 
         current++;   
       }); 
       $(".leftnav").click(function(){//click to see previous slider 
         sc.eq(current).children("span").hide(shortDelay/2); 
         sc.eq(current).hide(shortDelay/2); 
         current--;    
       }); 
       sliderUnit.hover(//when mouseover the slider, freeze slider,show the button 
         function(){ 
           delayFlag=true; 
           $(".slidernav").css("color","#fff"); 
           longDelay/=4; 
         }, 
         function(){ //when mouse leave, slider back to normal,hide the button 
           delayFlag=false; 
           $(".slidernav").css("color","transparent"); 
           longDelay*=4; 
         } 
       ); 
       var slider = function(){//where the slider starts 
         if(current>=(maxNo+1)) {current=0;} 
         if (current<=-1) {current=maxNo;} 
         $(document).queue(queueName,fq); 
         af(); 
       } 
       slider();//fire the loop 
     }; 
})(jQuery); 

工作,你可以看到我的演示在http://html5beta.com/a-demo-for-zxdslider/ 從螢火蟲什麼的閱讀。 它在jQuery 1.4.4和之前的工作,只是不工作在jQuery 1.5.0。 我真的找不到爲什麼。 滑塊僅僅因爲一些未知的原因而停下來。有什麼不對我的jQuery插件,不能在jQuery的1.5.0

+3

你看過了jQuery 1.5發行說明對可能影響任何重大的變動你插入? – 2011-02-14 00:56:03

+0

任何東西彈出[這裏](http://blog.jquery.com/2011/01/31/jquery-15-released/)? – alex 2011-02-14 01:02:40

回答

0

似乎是jQuery 1.5重新引入了1.3版本的bug。

如果隊列名稱不是'fx',那麼隊列就會中斷。

我在這裏提出了demo的問題,並提交了ticket

所以現在,我只希望從這個

var queueName = zxdCaller+"Queue";//queue-name 

改變這一行#13這個

var queueName = "fx";//queue-name 
相關問題