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
- fromnumberarraynumber or array of numbers
- tonumberarraynumber or array of numbers
- setterfunctioncaring function that accepts one numberargument
- durationnumberduration, in milliseconds
- easingfunctioneasing function frommina or custom
- callbackfunctioncallback function to execute when animationends
Returns: object animation object inmina format
- {
- id stringanimation id, consider it read-only,
- duration functiongets or sets the duration of the animation,
- easing functioneasing,
- speed functiongets or sets the speed of the animation,
- status functiongets or sets the status of the animation,
- stop functionstops the animation
- }
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);