1// Trigger CSS animations on scroll. 2// Detailed explanation can be found at http://www.bram.us/2013/11/20/scroll-animations/ 3 4// Looking for a version that also reverses the animation when 5// elements scroll below the fold again? 6// --> Check https://codepen.io/bramus/pen/vKpjNP 7 8jQuery(function ($) { 9 10 // Function which adds the 'animated' class to any '.animatable' in view 11 var doAnimations = function () { 12 13 // Calc current offset and get all animatables 14 var offset = $(window).scrollTop() + $(window).height(), 15 $animatables = $('.animatable'); 16 17 // Unbind scroll handler if we have no animatables 18 if ($animatables.length == 0) { 19 $(window).off('scroll', doAnimations); 20 } 21 22 // Check all animatables and animate them if necessary 23 $animatables.each(function (i) { 24 var $animatable = $(this); 25 var halfSize = $animatable.height() - ($animatable.height() / 1.5); 26 if (($animatable.offset().top + halfSize) < offset) { 27 $animatable.removeClass('animatable').addClass('animated'); 28 } 29 }); 30 31 }; 32 33 // Hook doAnimations on scroll, and trigger a scroll 34 $(window).on('scroll', doAnimations); 35 $(window).trigger('scroll'); 36 37});
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.