Skip to content

Instantly share code, notes, and snippets.



Created Dec 6, 2011
What would you like to do?
A function to apply animate.css classes dynamically
// Use the animate.css animations
function animate(element, effect, delay, callback) {
// Set a delay if needed
var animation = setTimeout(function () {
// Add the animation effect with classes
$(element).addClass('animate ' + effect);
// Check if the elemenr has been hidden to start with to prevent FOUC
if ($(element).css('visibility') == 'hidden') {
// If it has, show it (after the class has been added)
'visibility': 'visible'
if ($(element).css('display') == 'none') {
'display': 'inherit'
// Event triggered when the animation has finished
$(element).bind('animationend webkitAnimationEnd', function () {
// Remove the classes (so they can be triggered again if needed)
//$(element).removeClass('animate '+effect);
// Add a callback event
if (typeof callback == 'function') {;
}, delay);

This comment has been minimized.

Copy link

@aranw aranw commented Dec 6, 2011

Ha I saw this code on that site you tweeted... I just uploaded the Google Social Tracking code from that site...


This comment has been minimized.

Copy link

@craigmdennis craigmdennis commented Dec 6, 2011

This is now a plugin:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment