Ensure Animation
A simple JS module to ensure a CSS animation plays continuously through to the end animation frame.
See the Demo
Use Cases
Continue playing loading animation until a:
- Lazy loaded image is loaded
- User has clicked on a notification
- "Load more" ajax request has been completed
- Chain multiple animations to fire sequentially
Install
npm install ensure-animation --save
Usage
Given the following markup:
Import EnsureAnimation for use in your JS:
'.preloader'
Get instances
const preloaders = '.preloaders'
Stop single instance
const preload = '.preloader'0preload
Restart the animation
preload
Stop all instances
const preloaders = '.preloader'preloaders
Custom Options
Options can be passed directly to an instance using data attributes on the node itself, or by passing in an object of values.
And
const preloaders = '.preloader' // target to watch for class to be applied target : '.hero-image' // targets' class signaling animation should finish until : 'has-been-loaded' // target received this class upon finished animation, finishClass : 'custom-finished-class'