Animation
To create animation, we can change an object's size, position or color over time. We can create more complex animations by chaining several animations together.
Functions
object.animate(properties, duration = 1, easing = 'easeinoutelastic')
Animate any number of properties.
Parameters
- properties Object Object list the properties to animate and their target values.
- duration Number Duration of the animation in seconds.
- easing String Easing function to use for the animation.
Returns
Animationobject.grow(amount, duration = 1, easing = 'easeinoutelastic')
Grow the object by the specified number of pixels.
Parameters
- amount Number Number of pixels to grow the object by.
- duration Number Duration of the animation in seconds.
- easing String Easing function to use for the animation.
Returns
Animationobject.shrink(amount, duration = 1, easing = 'easeinoutelastic')
Shrink the object by the specified number of pixels.
Parameters
- amount Number Number of pixels to shrink the object by.
- duration Number Duration of the animation in seconds.
- easing String Easing function to use for the animation.
Returns
Animationobject.move(x, y, duration = 1, easing = 'easeinoutelastic')
Move the object the specified number of pixels in each direction.
Parameters
- x Number Number of pixels to move along the x axis.
- y Number Number of pixels to move along the y axis.
- duration Number Duration of the animation in seconds.
- easing String Easing function to use for the animation.
Returns
Animationobject.moveTo(x, y, duration = 1, easing = 'easeinoutelastic')
Move the object to a specific coordinate.
Parameters
- x Number Target x coordinate.
- y Number Target y coordinate.
- duration Number Duration of the animation in seconds.
- easing String Easing function to use for the animation.
Returns
AnimationEasing Functions
Linear
Ease In
Ease Out
Ease In Out
Ease In Elastic
Ease Out Elastic
Ease In Out Elastic
Chaining Animations Together
By default, when attempting to animate a property that is already being animated, the active animation will be stopped and replaced with the new one. By chaining animations together in the following pattern, the animations will play one after the other.
repeat(count = infinite)
Calling the repeat()
function after an animation, or
chain of animations, will repeat the animation or animations.
Parameters
- count Number Number of times to repeat the animation. If omitted the animation will repeat indefinately.