开发者

jQuery mouse queue/ css change problem

开发者 https://www.devze.com 2023-01-16 20:22 出处:网络
$(next).click(function(event) { even开发者_Python百科t.preventDefault(); if(parseInt($(container).css(\'left\')) <= (-(container_width-offset))) {
$(next).click(function(event) {
    even开发者_Python百科t.preventDefault();

    if(parseInt($(container).css('left')) <= (-(container_width-offset))) {
        $(container).animate({
                queue:false,
                left: "0px"
            }, speed, function() {

            });

    } else {
        $(container).animate({
                queue:false,
                left: "-="+offset+"px"
        }, speed, function() { });
    }
});

The preceding code animates a series of floating divs to slide left to right. It all works fine EXCEPT when someone clicks the mouse too quickly, the css doesn't update quick enough and sometimes it will roll to a blank div because this line doesn't register quick enough: parseInt($(container).css('left')) <= (-(container_width-offset))

How can I fix this?


add this line

if($(this).is(":animated")) return;

(after event.preventDefault();)

0

精彩评论

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