初始化Jquery动画函数的值

jquery animate function initialize the value

本文关键字:函数 动画 Jquery 初始化      更新时间:2023-09-26
$(element).delay(2000).animate(
    {
        scale: 1,
    },
    {
        duration: 1000,
        step: function(now) {
            scaleVal = now;
            $(element).attr("transform", "translate(" + centerX + " " + centerY + ") scale(" + scaleVal + ") translate(" + (-centerX) + " " + (-centerY) + ")");
        }
    }
);

现在比例值从0开始,以1结束,但我想从0.5开始,以1结束。

如何在动画函数中初始化缩放值?

您需要使用css函数

$(ele).css('scale', 0.5).animate({scale:1});