tail-end
Promise-wrapped CSS animations and transitions (async
/await
friendly).
Install
$ npm i tail-end --save
API
The following functions are exported:
animationEnd(node[, function])
transitionEnd(node[, function])
Both exports add a Promise-wrapped event handler to the node. The Promise removes the event listener and resolves itself when the event is triggered.
// bind the event, then trigger it nodeclassList
For usage with async
/await
you can pass in a function
as the second parameter. The function will be called in an animation frame after the event listener is bound, and passed the node
.
// define a sequence of animations/transitions with async/awaitconst sequence = async { await await await } // run the sequence
License
MIT. © 2018 Michael Cavalea