Skip to content

Instantly share code, notes, and snippets.

@szpakoli
Created October 16, 2013 13:59
Show Gist options
  • Save szpakoli/7008193 to your computer and use it in GitHub Desktop.
Save szpakoli/7008193 to your computer and use it in GitHub Desktop.
Using animate.css with a bit of jquery to expand functionality From http://josebrowne.com/open/tutorial-easy-css-animations-with-animate-css http://daneden.me/animate/
function animationClick(element, animation){
element = $(element);
element.click(
function() {
element.addClass('animated ' + animation);
//wait for animation to finish before removing classes
window.setTimeout( function(){
element.removeClass('animated ' + animation);
}, 2000);
}
);
};
function animationHover(element, animation){
element = $(element);
element.hover(
function() {
element.addClass('animated ' + animation);
},
function(){
//wait for animation to finish before removing classes
window.setTimeout( function(){
element.removeClass('animated ' + animation);
}, 2000);
}
);
};
//allow you to have a separate trigger element. (ex: hover or click logo animates sloganText)
$(document).ready(function(){
function animationClick(trigger, element, animation){
element = $(element);
trigger = $(trigger);
trigger.click(
function() {
element.addClass('animated ' + animation);
//wait for animation to finish before removing classes
window.setTimeout( function(){
element.removeClass('animated ' + animation);
}, 2000);
});
}
function animationHover(trigger, element, animation){
element = $(element);
trigger = $(trigger);
trigger.hover(
function() {
element.addClass('animated ' + animation);
},
function(){
//wait for animation to finish before removing classes
window.setTimeout( function(){
element.removeClass('animated ' + animation);
}, 2000);
});
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment