ractive.animate()
edit this pageSimilar to ractive.set(), this will update the data and re-render any affected mustaches (and notify observers).
All animations are handled by a global timer that is shared between Ractive instances (and which only runs if there are one or more animations still in progress), so you can trigger as many separate animations as you like without worrying about timer congestion. Where possible, requestAnimationFrame is used rather than setTimeout.
Numeric values and strings that can be parsed as numeric values can be interpolated. Objects and arrays containing numeric values (or other objects and arrays which themselves contain numeric values, and so on recursively) are also interpolated.
If an animation is started on a keypath which is already being animated, the first animation is cancelled. (Currently, there is no mechanism in place to prevent collisions between e.g. ractive.animate('foo', { bar: 1 }) and ractive.animate('foo.bar', 0).)
ractive.animate( keypath, value[, options] )
Returns an
Objectwith astopmethod, which cancels the animation.keypath
StringThe keypath to animate.
value
NumberorStringorObjectorArrayThe value to animate to.
options
ObjectSettings for the animation. All properties are optional:
duration
NumberDefaults to 400. How many milliseconds the animation should run for
easing
StringorFunctionDefaults to
'linear'. The name of an easing function on Ractive.easing, or the easing function itselfstep
FunctionA function to be called on each step of the animation. Receives
tandvalueas arguments, wheretis the animation progress (between 0 and 1, as determined by the easing function) andvalueis the intermediate value attcomplete
FunctionA function to be called when the animation completes, with the same argument signature as
step(i.e.tis1, andvalueis the destination value)ractive.animate( map[, options] )
Returns an
Objectwith astopmethod, which cancels the animations.map
ObjectA map of
keypath: valuepairsoptions
ObjectAs above.