UNPKG

zpt

Version:

Zenon Page Templates - JS (ZPT-JS)

49 lines (40 loc) 1.27 kB
/* Class CSSAnimationManager */ "use strict"; module.exports = (function() { var animate = function( dictionaryAction, node, callback ) { // Run callback and return if there is no animation if ( ! dictionaryAction.animation ){ if ( callback ){ callback(); }; return; } // Set the animation node.style.animation = 'none'; setTimeout( function() { // Set the animationend listener var animationendCallback = function( event ){ if ( callback ){ callback(); } }; //node.removeEventListener( 'animationend', animationendCallback ); node.addEventListener( 'animationend', animationendCallback ); // Set the animation node.style.animation = dictionaryAction.animation; }, 10 ); }; var reset = function( node ) { node.style.animation = 'none'; }; var self = { animate: animate, reset: reset }; return self; })();