Tuesday, December 27, 2016

use of animate.css with callback function

I need to integrate the animate.css in rails 5 project. Well its pretty straight forward to integrate, I used gem animate.css-rails. I also require a callback when animation is done for this I need to write a javascript function.

var animateCss = function (element, animationName, callback) {
    var animationEnd = 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend';
    element.addClass('animated ' + animationName).one(animationEnd, function () {
        element.removeClass('animated ' + animationName);
        if (typeof(callback) == 'function') {
            callback();
        }
    });
}
 
 
 
 

No comments: