JQuery动画留下什么都没做

时间:2011-11-07 20:48:39

标签: jquery jquery-animate

我的代码的以下几行绝对没有。

changeqnt -= $(curwidth).width() - (($(curwidth).width() - $(nextwidth).width()) / 2);
$('.picstrip').animate({left: changeqnt + 'px'}, 400, function(){ galactive = 1 });

它们是更大函数的一部分,见下文,非常奇怪的是使用CSS3 webkit,但这个JQuery回退应该很简单,虽然它将执行不透明度函数但它不会执行。

CODE

$(window).load(function(){
    var picstripstart = (($('.currentwindow').width() - $('.gallery img:first').width()) / 2);
    var galqnt = ($('.gallery img').length -1);
    var galactive = 1;
    var changeqnt = picstripstart;
    $('.picstrip').animate({left: '+=' + picstripstart + 'px', leaveTransforms:true}, 20);
    $('.gallery img').animate({opacity:0.6, leaveTransforms:true}, 400);
    $('.gallery img:first').animate({opacity:1, leaveTransforms:true}, 400).addClass('galeryshown');

    $('a.arrows').click(function(){

        if(galactive == 1){
            galactive = 0;
            var curwidth = $('.gallery img.galeryshown');
            var nextwidth = $(curwidth).next();
            var prevwidth = $(curwidth).prev();

            if($(this).attr('class') == 'arrows r') {
                if($(curwidth).index() == galqnt) { galactive = 1; return false }
                else {
                    $(curwidth).removeClass('galeryshown').animate({opacity: 0.6, leaveTransforms:true}, 400);
                    $(nextwidth).addClass('galeryshown').animate({opacity: 1, leaveTransforms:true}, 400);
                    changeqnt -= $(curwidth).width() - (($(curwidth).width() - $(nextwidth).width()) / 2);
                    $('.picstrip').animate({left: changeqnt + 'px', leaveTransforms:true}, 400, function(){ galactive = 1 });
                }
            }
            if($(this).attr('class') == 'arrows l') {
                if($(curwidth).index() == 0) { galactive = 1; return false }
                else {
                    $(curwidth).removeClass('galeryshown').animate({opacity: 0.6, leaveTransforms:true}, 400);
                    $(prevwidth).addClass('galeryshown').animate({opacity: 1, leaveTransforms:true}, 400);
                    changeqnt += $(curwidth).width() - (($(curwidth).width() - $(prevwidth).width()) / 2);
                    $('.picstrip').animate({left: changeqnt + 'px', leaveTransforms:true}, 400, function(){ galactive = 1 });
                }
            }
        }

        return false
    });

    $('.gallery').mouseenter(function(){
        $('a.arrows').animate({opacity:1, leaveTransforms:true}, 400);
    });
    $('.gallery').mouseleave(function(){
        $('a.arrows').animate({opacity:0.5, leaveTransforms:true}, 400);
    });


});

1 个答案:

答案 0 :(得分:0)

奇怪的是,我刚刚遇到了类似的问题。尝试将元素位置显式设置为relative,看看是否有所不同。

$('.picstrip').css({ "position" : "relative" });