elementAnimate.js takes the usual element.animate() arguments and plays an animation, with some handy improvements:
- automatically fills in partial keyframes based on initial styles
- set style before delayed animation
- set style after animation finished
Say we have a div with background-color: red and color: white.
Running
div.animate([null, { "background-color": "blue" }, null, { "background-color": "pink"}], 300)is equivalent to running
div.animateBase([{ "background-color": "red" }, { "background-color": "blue" }, { "background-color": "red" }, { "background-color": "pink"}], 300)(animateBase is the original element.animate() function).
Before an animation with delay starts, the styles of the first keyframe is applied to the element.
When an animation finishes, the styles of the final keyframe is applied to the element.
MIT license.