Created
March 4, 2016 16:58
-
-
Save 1ncrement/cf64bd1804359d30c202 to your computer and use it in GitHub Desktop.
jQuery+CSSAnimation
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
<script type="text/javascript">//<![CDATA[ | |
$(function(){ | |
function onScrollInit( items, trigger ) { | |
items.each( function() { | |
var osElement = $(this), | |
osAnimationClass = osElement.attr('data-os-animation'), | |
osAnimationDelay = osElement.attr('data-os-animation-delay'); | |
osElement.css({ | |
'-webkit-animation-delay': osAnimationDelay, | |
'-moz-animation-delay': osAnimationDelay, | |
'animation-delay': osAnimationDelay | |
}); | |
var osTrigger = ( trigger ) ? trigger : osElement; | |
osTrigger.waypoint(function() { | |
osElement.addClass('animated').addClass(osAnimationClass); | |
},{ | |
triggerOnce: true, | |
offset: '90%' | |
}); | |
}); | |
} | |
onScrollInit( $('.os-animation') ); | |
onScrollInit( $('.staggered-animation'), $('.staggered-animation-container') ); | |
});//]]> | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment