1jQuery(document).ready(function($){ 2 var timelineBlocks = $('.eael-content-timeline-block'), 3 offset = 0.8; 4 5 //hide timeline blocks which are outside the viewport 6 hideBlocks(timelineBlocks, offset); 7 8 //on scolling, show/animate timeline blocks when enter the viewport 9 $(window).on('scroll', function(){ 10 (!window.requestAnimationFrame) 11 ? setTimeout(function(){ showBlocks(timelineBlocks, offset); }, 100) 12 : window.requestAnimationFrame(function(){ showBlocks(timelineBlocks, offset); }); 13 }); 14 15 function hideBlocks(blocks, offset) { 16 blocks.each(function(){ 17 ( $(this).offset().top > $(window).scrollTop()+$(window).height()*offset ) && $(this).find('.eael-content-timeline-img, .eael-content-timeline-content').addClass('is-hidden'); 18 }); 19 } 20 21 function showBlocks(blocks, offset) { 22 blocks.each(function(){ 23 ( $(this).offset().top <= $(window).scrollTop()+$(window).height()*offset && $(this).find('.eael-content-timeline-img').hasClass('is-hidden') ) && $(this).find('.eael-content-timeline-img, .eael-content-timeline-content').removeClass('is-hidden').addClass(''); 24 }); 25 } 26 27 /** 28 * Timeline Animation Script 29 */ 30 var getElementsInArea = (function(docElm){ 31 var viewportHeight = docElm.clientHeight; 32 33 return function(e, opts){ 34 var found = [], i; 35 36 if( e && e.type == 'resize' ) 37 viewportHeight = docElm.clientHeight; 38 39 for( i = opts.elements.length; i--; ){ 40 var elm = opts.elements[i], 41 pos = elm.getBoundingClientRect(), 42 topPerc = pos.top / viewportHeight * 100, 43 bottomPerc = pos.bottom / viewportHeight * 100, 44 middle = (topPerc + bottomPerc)/2, 45 inViewport = middle > opts.zone[1] && 46 middle < (100-opts.zone[1]); 47 48 elm.classList.toggle(opts.markedClass, inViewport); 49 50 if( inViewport ) 51 found.push(elm); 52 } 53 }; 54 })(document.documentElement); 55 56 /** 57 * Use Case 58 */ 59 window.addEventListener('scroll', f) 60 window.addEventListener('resize', f) 61 62 function f(e){ 63 getElementsInArea(e, { 64 elements : document.querySelectorAll('.eael-content-timeline-block'), 65 markedClass : 'highlight', 66 zone : [15, 15] // percentage distance from top & bottom 67 }); 68 } 69});
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.