1// Return the visible amount of px 2// of any element currently in viewport. 3// https://stackoverflow.com/a/27462500/3481803 4// http://jsfiddle.net/RokoCB/tw6g2oeu/7/ 5/** 6 * $(".example").inViewport(function(px){ if(px) $(this).addClass("class"); }, {padding:0}); 7 * 8*/ 9;(function($, win) { 10 $.fn.inViewport = function(cb, options) { 11 12 // Defaults 13 var settings = $.extend({ 14 padding: 0 // Add delay 15 }, options ); 16 17 return this.each(function(i,el){ 18 //var func = function(px){if(px) $(this).addClass(settings.class+' '+$(this).data('animation'));}; 19 function visPx(){ 20 var H = $(this).height(), 21 r = el.getBoundingClientRect(), t=r.top+settings.padding, b=r.bottom+settings.padding; 22 return cb.call(el, Math.max(0, t>0? H-t : (b<H?b:H))); 23 } visPx(); 24 $(win).on("resize scroll", visPx); 25 }); 26 }; 27}(jQuery, window));
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.