jquery animate function initialize the value

◇◆丶佛笑我妖孽 提交于 2019-12-25 11:09:28

问题


$(element).delay(2000).animate(
    {
        scale: 1,
    },
    {
        duration: 1000,
        step: function(now) {
            scaleVal = now;
            $(element).attr("transform", "translate(" + centerX + " " + centerY + ") scale(" + scaleVal + ") translate(" + (-centerX) + " " + (-centerY) + ")");
        }
    }
);

Now the scale value starts from 0 and ends up in 1 but instead of this I want to start from 0.5 and ends up in 1.

How can I initialize the scale value in animate function?


回答1:


you need to use css function

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


来源:https://stackoverflow.com/questions/17037687/jquery-animate-function-initialize-the-value

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!