All Projects → vigetlabs → ensure-animation

vigetlabs / ensure-animation

Licence: other
Ensure animation runs until class loaded

Programming Languages

javascript
184084 projects - #8 most used programming language
CSS
56736 projects
HTML
75241 projects

Projects that are alternatives of or similar to ensure-animation

async-preloader
Assets preloader using ES2017 async/await and fetch.
Stars: ✭ 44 (-42.11%)
Mutual labels:  preloader
babl
JSON templating on steroids
Stars: ✭ 29 (-61.84%)
Mutual labels:  preloader
Friendly Code Editor
Try this Friendly Code Editor. You'll love it. I made it with a lot of effort. It has some great features. I will update it adequately later. Very helpful for developers. Enjoy and share.
Stars: ✭ 20 (-73.68%)
Mutual labels:  preloader
wp-better-resource-hints
A WordPress plugin to help better manage resource hinting (preloading, prefetching, server pushing).
Stars: ✭ 18 (-76.32%)
Mutual labels:  preloader
resloader
🎉A image preloaded plugin and can display the loaded image progress bar
Stars: ✭ 20 (-73.68%)
Mutual labels:  preloader
pure
Beautifully crafted minimalistic loading animations.
Stars: ✭ 14 (-81.58%)
Mutual labels:  preloader
prefetch-image
Prefetch all images for your web app, especially for mobile/h5 promotion pages
Stars: ✭ 22 (-71.05%)
Mutual labels:  preloader

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:

<figure>
  <img src="large-image.jpg" class="hero lazyload">
  <div class="preloader" data-ensure-target=".hero" data-ensure-until=".lazyloaded" data-ensure-finish-class="fade-in"></div>
</figure>

Import EnsureAnimation for use in your JS:

import EnsureAnimation from 'ensure-animation'
new EnsureAnimation('.preloader')

Get instances

const preloaders = new EnsureAnimation('.preloaders')

Stop single instance

const preload = new EnsureAnimation('.preloader')[0]
preload.finish()

Restart the animation

preload.restart()

Stop all instances

const preloaders = new EnsureAnimation('.preloader')
preloaders.each((preloader) => preloader.finish())

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.

<figure>
  <img src="large-image.jpg" class="hero lazyload">
  <div data-ensure-target=".hero"
       data-ensure-until=".lazyloaded"
       data-ensure-finish-class="fade-in"
       class="preloader"></div>
</figure>

And

const preloaders = new EnsureAnimation('.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'
})
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].