开发者

what is wrong with my jquery plugin,can not work in jquery 1.5.0

开发者 https://www.devze.com 2023-02-10 12:06 出处:网络
/* ------------------------------------------------------------------------ plugin-name:zxdSlider Developped By: ZHAO Xudong -> http://html5beta.com
/* ------------------------------------------------------------------------
    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); 

You can see my demo at http://html5beta.com/a-demo-for-zxdslider/ read it from firebug or something. it works in jquery 1.4.4 and before,just do not work in jquery 1.5.0. i really can not find it out why. the slider just stop for some unknown reason.


It seems to be that jQuery 1.5 has reintroduced a bug that was also in version 1.3.

If the queue name is anything other than 'fx' then the queue breaks.

I made a demo of the problem here, and submitted a ticket.

So for now, I'd just change this line #13 from this

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

to this

var queueName = "fx";//queue-name
0

精彩评论

暂无评论...
验证码 换一张
取 消