Text Animation JS
A small animation library inspired by this tweet.
Installation
Just paste npm install text-animation-js
in the console.
How to use it
Just import the component and pass a HTML element to it.
; const animation = document;
Call new Animation()
will return an animation instance.
Also you need to import the css styles:
;
Animation
Configuration
Animation
accepts two parameters, a HTML element and callback that will be called on animation end.
Methods
Each Animation
instance has three methods play
, pause
, and reset
:
Play
Call animation.play()
will start the animation, it returns the animation instance.
document;
This will start the animation when the button
is clicked.
Pause
Call animation.pause()
will pause the animation, it returns the animation instance.
document;
This will pause the animation when the button
is clicked.
Reset
Call animation.reset()
will reset the animation, it returns the animation instance.
document;
This will reset the animation when the button
is clicked.
Controlling multiple animations
This is a helper to control multiple animations with one call.
Configuration
AnimationList
accepts one parameter, an Animation
array, this will be the animations to control.
const animations = element1 element2 element3; const animationList = animations;
Methods
Each AnimationList
instance has three methods play
, pause
, and reset
:
Play
Call animationList.play()
will start the animations, it will wait for each animation to finish before starting the next one.
document;
Pause
Call animationList.pause()
will pause all the animations.
document;
Reset
Call animationList.reset()
will reset all the animations.
document;
Demos
You can find some demos here.
TODO
- animaciones personalizadas
- unit testing?
Issues
- callback hell, Animation.play solo agrega callbacks, hay que limpiarlos después de lanzárlos
- AnimationList pause no funciona justo al final de la transición