1 $( document ).ready(function() { 2 3 $(function() { 4 5 var $counters = $('.count'); //contains all elements of count class 6 7 var $window = $(window); 8 9 $window.on('scroll', function(e) { 10 $counters.each(function(i, elem) { //loop through each element 11 console.log(i) 12 if ($(this).hasClass('counted')) // check if already animated 13 return; 14 animateCounter($(this)); 15 }); 16 }); 17 }); 18 19 function animateCounter(elem) { 20 var winTop = $(window).scrollTop(); // calculate distance from top of window 21 var winBottom = winTop + $(window).height(); 22 var elemTop = $(elem).offset().top; // element distance from top of page 23 var elemBottom = elemTop + $(elem).height(); 24 25 if ((elemBottom <= winBottom) && (elemTop >= winTop)) { 26 $(elem).each(function() { 27 var $this = $(this); 28 jQuery({ 29 Counter: 0 30 }).animate({ 31 Counter: $this.attr('data-count') 32 }, { 33 duration: 4000, 34 easing: 'swing', 35 step: function() { 36 $this.text(Math.ceil(this.Counter)); 37 } 38 }); 39 $this.removeClass('count').addClass('counted'); 40 }); 41 } 42 } 43 44 });
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.