Skip to content

Instantly share code, notes, and snippets.

@1ncrement
Created March 4, 2016 16:58
Show Gist options
  • Save 1ncrement/cf64bd1804359d30c202 to your computer and use it in GitHub Desktop.
Save 1ncrement/cf64bd1804359d30c202 to your computer and use it in GitHub Desktop.
jQuery+CSSAnimation
<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