Last active
January 4, 2016 09:09
-
-
Save gfazioli/8599718 to your computer and use it in GitHub Desktop.
Animate.css jQuery Plugin
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
/* Use this additional style to hide element at start */ | |
.animate | |
{ | |
visibility : hidden; | |
} | |
.animated | |
{ | |
visibility : visible; | |
} |
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
<div id="playground"> | |
<h1 id="title-1" class="animate" data-animate-effect="bounceIn"> | |
Hello World | |
</h1> | |
<h2 id="title-1" class="animate" data-animate-effect="bounceInLeft" data-animate-by="title-1"> | |
Start After title | |
</h2> | |
</div> |
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 Plugin for Animate.css - http://daneden.me/animate | |
* | |
* @author =undo= <[email protected]> | |
* @copyright Copyright (C) 2012-2014 wpXtreme Inc. All Rights Reserved. | |
* @date 2014-01-24 | |
* @version 1.0.0 | |
* | |
* Gist https://gist.github.com/gfazioli/8599718 | |
* | |
*/ | |
;(function ( $, window, document, undefined ) | |
{ | |
"use strict"; | |
$.fn.wpxAnimate = function () | |
{ | |
return this.each( function () | |
{ | |
var container = $( this ); | |
container | |
.find( '.animate' ) | |
.not( '.animated' ) | |
.not( '[data-animate-by]' ) | |
.each( | |
function ( i, e ) | |
{ | |
var current = $( e ); | |
current | |
.addClass( 'animated ' + current.data( 'animate-effect' ) ) | |
.one( 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', _applyEffectBy ); | |
} | |
); | |
function _applyEffectBy() | |
{ | |
var current = $( this ), id = current.attr( 'id' ); | |
if ( id ) { | |
container | |
.find( '[data-animate-by="' + id + '"]' ) | |
.not( '.animated' ).each( function () | |
{ | |
$( this ) | |
.addClass( 'animated ' + $( this ).data( 'animate-effect' ) ) | |
.one( 'webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', _applyEffectBy ); | |
} ); | |
} | |
} | |
} ); | |
}; | |
})( jQuery, window, document ); |
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
$( '#playground' ).wpxAnimate(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment