1/*! inViewport 0.0.1 2 * jQuery plugin by Moob 3 * ======================== 4 * (requires jQuery) 5 */ 6(function ($) { 7 8 var vph=0; 9 function getViewportDimensions(){ 10 vph = Math.max(document.documentElement.clientHeight, window.innerHeight || 0); 11 } 12 getViewportDimensions(); 13 //on resize/scroll 14 $(window).on('resize orientationChanged', function(){ 15 getViewportDimensions(); 16 }); 17 18 $.fn.inViewport = function (whenInView, whenNotInView) { 19 return this.each(function () { 20 var el = $(this), 21 inviewalreadycalled = false, 22 notinviewalreadycalled = false; 23 //on resize/scroll 24 $(window).on('resize orientationChanged scroll', function(){ 25 checkInView(); 26 }); 27 function checkInView(){ 28 var rect = el[0].getBoundingClientRect(), 29 t = rect.top, 30 b = rect.bottom; 31 if(t<vph && b>0){ 32 if(!inviewalreadycalled){ 33 whenInView.call(el); 34 inviewalreadycalled = true; 35 notinviewalreadycalled = false; 36 } 37 } else { 38 if(!notinviewalreadycalled){ 39 whenNotInView.call(el); 40 notinviewalreadycalled = true; 41 inviewalreadycalled = false; 42 } 43 } 44 } 45 //initial check 46 checkInView(); 47 }); 48 } 49}(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.