Firefox忽略了变换/跳过变换风格的变化

时间:2013-02-19 19:09:29

标签: jquery css performance firefox animation

当我使用

为固定图层设置动画时
$('#block1').click(function() {
    $('#block1').stop().animate({
        translateY: -$(window).width()
    }, {
        duration: 600,
        step: function(now, fx) {
            moveTo(this, now, 0);
            moveTo($('#block2')[0], now, 0);
        }
    });
});

$('#block2').click(function() {
    $('#block1').stop().animate({
        translateY: 0
    }, {
        duration: 600,
        step: function(now, fx) {
            moveTo(this, now, 0);
            moveTo($('#block2')[0], now, 0);
        }
    });
});

function moveTo(elem, x, y) {
    elem.style['WebkitTransform'] = 'translate('+x+'px, '+y+'px)';
    elem.style['transform'] = 'translate('+x+'px, '+y+'px)';
}

我做了一个小提示来表明问题:fiddle example

这里有一个截屏@ 30fps:Screen capture video

当我点击“bla bla ...”时,在FF 19.0中

动画效果很好。

但是当我点击绿色矩形时,有时/只有绿色矩形是动画,而文本显示延迟而没有动画。

在FF 19.0 @ big screen / frame-size和windows 7

中测试

css看起来像:

body {
    background: url(http://whiteboard.is/img/dot-pattern.png), #cccccc;
}
#block1 {
    width: 100%;
    height: 120%;
    position: fixed;
}
h1, h2 {
    display: inline-block;
    line-height: 1;
    text-transform: uppercase;
    background: #ffffff;
    font-weight: 900;
    padding: 0.1em 0.2em;
    position: relative;
    margin: 0 0 10px 0;

    color: #3a3d30;
    font-size: 2em;
    z-index: 5;

    -moz-box-shadow: 0px 0px 18px 5px rgba(0, 0, 0, 0.4);
    -webkit-box-shadow: 0px 0px 18px 5px rgba(0, 0, 0, 0.4);
    box-shadow: 0px 0px 18px 5px rgba(0, 0, 0, 0.4);
}
.child1 {
    width: 600px;
    left: 50%;

    text-align: center;
    position: absolute;
    margin-left: -300px;
    margin-top: 80px;
    z-index: 9;

    -webkit-transform: translate3d(0, 0, 0);
    -webkit-transform-style: preserve-3d;
    -webkit-backface-visibility: hidden;
    -webkit-perspective: 1000;

    -moz-transform: translate3d(0, 0, 0);
    -moz-transform-style: preserve-3d;
    -moz-backface-visibility: hidden;
    -moz-perspective: 1000;

    transform: translate3d(0, 0, 0);
    transform-style: preserve-3d;
    backface-visibility: hidden;
    perspective: 1000;
}
#block2 {
    width: 600px;
    height: 400px;
    position: fixed;
    left: 150%;
    margin-left: -300px;
    background: #009900;
    z-index: 20;
}

0 个答案:

没有答案