Tiny ~0.8kb
javascript library with cross-browser methods to handle CSS ontransitionend
and onanimationend
event — AKA CSS animation and transition callbacks.
Quick usage example of the onceTransitionEnd
wac method.
wac.onceTransitionEnd(element).then(function(event) {
// ... do something
});
Access the demo at https://web-animation.caferati.me
From the NPM registry
using npm or yarn just install @rcaferati/wac
package.
npm install --save @rcaferati/wac
or
yarn add --save @rcaferati/wac
For all the following examples please consider the following HTML markup.
<style>
.animated {
transition: transform 0.4s linear;
}
.move {
transform: translateX(100px);
}
</style>
<div class="container">
<div class="box"></div>
</div>
<script src="/path/to/wac.min.js"></script>
<script>
var box = document.querySelector('.box');
box.classList.add('animated');
box.classList.add('move');
onceTransitionEnd(box).then(function(event) {
// ... do something
});
</script>
import { onceTransitionEnd } from '@rcaferati/wac';
const element = document.querySelector('.box');
// here we're just simulating the addition of a class with some animation/transition
element.classList.add('animated');
element.classList.add('move');
// if you are using the transition css property
onceTransitionEnd(element).then((event) => {
// ... do something
});
element
<[HTML element]> html element on which the transition is happeningoptions
<[object]>tolerance
<[integer]> used in case of pseudo-element animationsproperty
<[string]> animated property to check before calling the callback
element
<[HTML element]> html element on which the transition is happeningoptions
<[object]>tolerance
<[integer]> used in case of pseudo-element animationsproperty
<[string]> animated property to check before calling the callback
frames
<[integer]> Number of frames to skipcallback
<[function]> function called after the skipped frames
callback
<[function]> function called after the skipped frame
- Checkout my Portfolio Website
- Follow on GitHub
- Connect on LinkedIn
MIT. Copyright (c) 2018 Rafael Caferati.