Last active
March 29, 2020 13:43
-
-
Save thexmanxyz/b29a575f3f8b4a90bdad59d6e97a650d to your computer and use it in GitHub Desktop.
WOW.js Reanimate Single Elements without init() - delayed
This file contains hidden or 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
// If you want to explicitly trigger an animation for certain WOW.js elements again. No need to call `init()` and also not wanted (all elements are reset): | |
var triggerAnimation = function(selector, animation) { | |
var $element = $(selector); // get element | |
// re-apply animation (style and class) | |
var applyAnimation = function(){ | |
$element = $(selector); | |
$element.addClass('wow ' + animation + ' animated'); | |
$element.attr('style', 'visibility: visible; animation-name: ' + animation + ';'); | |
}; | |
// remove elements if not currently animated and re-apply | |
if(!$element.hasClass('animated')) { | |
$element.removeAttr('style'); | |
$element.removeClass('wow').removeClass(animation) | |
// re-apply styling after 25ms delay | |
setTimeout(applyAnimation, 25); | |
} | |
}; | |
triggerAnimation('.your_selector, 'zoomIn'); // element to reanimate and animation |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment