1(function($){ 2 $.fn.edsViewportChecker = function(useroptions){ 3 4 var options = { 5 classToRemove: 'eds-scroll-hidden', 6 classToAdd: 'eds-scroll-visible', 7 offset: 75, 8 callbackFunction: function(elem){} 9 }; 10 $.extend(options, useroptions); 11 12 var $elem = this; 13 14 this.checkElements = function(){ 15 16 var windowHeight = $(window).height(), 17 viewportTop = $(document).scrollTop(), 18 viewportBottom = (viewportTop + windowHeight); 19 20 $elem.each(function(){ 21 var $obj = $(this); 22 var scroll_offset = $obj.attr('eds_scroll_offset'); 23 24 if ($obj.hasClass(options.classToAdd)){ 25 return; 26 } 27 28 var elemTop = ''; 29 if(scroll_offset != null && scroll_offset != ''){ 30 elemTop = Math.round( $obj.offset().top ) + Math.round(Number(scroll_offset) * $obj.height() * 0.01), 31 elemBottom = elemTop + ($obj.height()); 32 }else{ 33 elemTop = Math.round( $obj.offset().top ) + Math.round(options.offset * $obj.height() * 0.01), 34 elemBottom = elemTop + ($obj.height()); 35 } 36 37 // Add class if in viewport 38 if ((elemTop < viewportBottom) && (elemBottom > viewportTop)){ 39 $obj.addClass(options.classToAdd); 40 $obj.removeClass(options.classToRemove); 41 options.callbackFunction($obj); 42 } 43 }); 44 }; 45 46 $( window ).on( "scroll", $.throttle( 250, this.checkElements ) ); 47 //For applying the onscroll part only after the user scroll atleast ones event after the item is in view port, just comment this out 48 this.checkElements(); 49 50 }; 51})(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.