在Jquery中的步骤函数中更改css(转换)不起作用

时间:2015-10-07 08:51:40

标签: jquery jquery-animate

它仅适用于旋转,或仅适用于刻度,但不适用于两者。

$({rotation: 0, scale: 1}).animate({
            rotation: 360,
            scale: 3
        }, {
            duration: 4000,
            step: function (now, fx) {

                var rot, scl;
                if (fx.prop === 'rotation') {
                    rot = now;
                }
                if (fx.prop === 'scale') {
                    scl = now;
                }
                $('.inner').css('transform', 'scale(' + scl + ') rotate(' + rot + 'deg)');

            }
        });

inner只是外部div元素中的h1标记。

1 个答案:

答案 0 :(得分:0)

试试这个:

step: function (now, fx) {

    $('#inner').css('transform', 'scale(' + now + ') rotate(' + now + 'deg)');

}

rot = now;scl = now;都使用来自步骤函数参数的now

DEMO