目录
当前位置: 首页 > 文档资料 > Snap.svg 英文文档 >

Snap.animate(from, to, setter, duration, [easing], [callback])

优质
小牛编辑
128浏览
2023-12-01

Runs generic animation of one number into another with a caring function

Parameters

  1. fromnumberarraynumber or array of numbers
  2. tonumberarraynumber or array of numbers
  3. setterfunctioncaring function that accepts one numberargument
  4. durationnumberduration, in milliseconds
  5. easingfunctioneasing function frommina or custom
  6. callbackfunctioncallback function to execute when animationends

Returns: object animation object inmina format

  1. {
    1. id stringanimation id, consider it read-only,
    2. duration functiongets or sets the duration of the animation,
    3. easing functioneasing,
    4. speed functiongets or sets the speed of the animation,
    5. status functiongets or sets the status of the animation,
    6. stop functionstops the animation
  2. }
var rect = Snap().rect(0, 0, 10, 10);
Snap.animate(0, 10, function (val) {
rect.attr({
x: val
});
}, 1000);
// in given context is equivalent to
rect.animate({x: 10}, 1000);