Detecting CSS Animation and Transition End with JavaScript.
Last active
September 12, 2015 19:14
-
-
Save petermac-/429bc799f3695896018f to your computer and use it in GitHub Desktop.
detect-animation-end-examples.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// jQuery example | |
// http://osvaldas.info/examples/detecting-css-animation-transition-end-with-javascript/oncssanimationend.js | |
$( '.item' ).addClass( 'disappear' ).onCSSAnimationEnd( function() | |
{ | |
$( this ).remove(); | |
}); | |
// JavaScript example | |
// http://osvaldas.info/examples/detecting-css-animation-transition-end-with-javascript/jquery.oncssanimationend.js | |
var item = document.querySelector( '.item' ); | |
item.classList.add( 'disappear' ); | |
item.onCSSAnimationEnd( function() | |
{ | |
item.parentNode.removeChild( item ); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment