1/* 2* 15. Animate.js 3*/ 4var docElem = window.document.documentElement; 5 6 function getViewportH() { 7 var client = docElem['clientHeight'], 8 inner = window['innerHeight']; 9 10 if( client < inner ) 11 return inner; 12 else 13 return client; 14 } 15 16 function scrollY() { 17 return window.pageYOffset || docElem.scrollTop; 18 } 19 20 function getOffset( el ) { 21 var offsetTop = 0, offsetLeft = 0; 22 do { 23 if ( !isNaN( el.offsetTop ) ) { 24 offsetTop += el.offsetTop; 25 } 26 if ( !isNaN( el.offsetLeft ) ) { 27 offsetLeft += el.offsetLeft; 28 } 29 } while( el = el.offsetParent ) 30 31 return { 32 top : offsetTop, 33 left : offsetLeft 34 } 35 } 36 37 function inViewport( el, h ) { 38 var elH = el.offsetHeight, 39 scrolled = scrollY(), 40 viewed = scrolled + getViewportH(), 41 elTop = getOffset(el).top, 42 elBottom = elTop + elH, 43 // if 0, the element is considered in the viewport as soon as it enters. 44 // if 1, the element is considered in the viewport only when it's fully inside 45 // value in percentage (1 >= h >= 0) 46 h = h || 0; 47 48 return (elTop + elH * h) <= viewed && (elBottom) >= scrolled; 49 } 50(function ( $ ) { 51 52 'use strict'; 53 54 $.fn.animateIn = function(){ 55 56 var el = $(this); 57 var height = $(window).innerHeight(); 58 59 el.css('opacity', '0'); 60 61 $(window).scroll(function(){ 62 63 el.each(function(){ 64 65 el.css('opacity', '100'); 66 67 var scrollTop = $(window).scrollTop(); 68 var obj = $(this); 69 var offset = obj.offset(); 70 var top = offset.top; 71 var distance = (top - scrollTop); 72 73 if( distance < screen.availHeight-100 ){ 74 var incoming = $(this).data('animate'); 75 $(this).addClass('animated ' + incoming); 76 } 77 78 }); 79 80 }); 81 82 }; 83 84}( jQuery ));
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.