1 2 3 4var wrapTop = $(".digital").offset().top; 5var istrue = true; 6$(window).on("scroll", 7 function() { 8 var s = $(window).scrollTop(); 9 if (s > wrapTop - 900 && istrue) { 10 $(".timer").each(count); 11 12 function count(a) { 13 var b = $(this); 14 a = $.extend({}, 15 a || {}, 16 b.data("countToOptions") || {}); 17 b.countTo(a) 18 }; 19 istrue = false; 20 }; 21 }) 22//è®¾ç½®è®¡æ° 23$.fn.countTo = function(options) { 24 options = options || {}; 25 return $(this).each(function() { 26 //å½åå ç´ çé项 27 var settings = $.extend({}, $.fn.countTo.defaults, { 28 from: $(this).data('from'), 29 to: $(this).data('to'), 30 speed: $(this).data('speed'), 31 refreshInterval: $(this).data('refresh-interval'), 32 decimals: $(this).data('decimals') 33 }, options); 34 //æ´æ°å¼ 35 var loops = Math.ceil(settings.speed / settings.refreshInterval), 36 increment = (settings.to - settings.from) / loops; 37 //æ´æ¹åºç¨ååé 38 var self = this, 39 $self = $(this), 40 loopCount = 0, 41 value = settings.from, 42 data = $self.data('countTo') || {}; 43 $self.data('countTo', data); 44 //妿æé´æï¼æ¾å°å¹¶æ¸ é¤ 45 if (data.interval) { 46 clearInterval(data.interval); 47 }; 48 data.interval = setInterval(updateTimer, settings.refreshInterval); 49 //åå§åèµ·å§å¼ 50 render(value); 51 52 function updateTimer() { 53 value += increment; 54 loopCount++; 55 render(value);
56 if (typeof(settings.onUpdate) == 'function') { 57 settings.onUpdate.call(self, value); 58 } 59 if (loopCount >= loops) { 60 //ç§»åºé´é 61 $self.removeData('countTo'); 62 clearInterval(data.interval); 63 value = settings.to; 64 if (typeof(settings.onComplete) == 'function') { 65 settings.onComplete.call(self, value); 66 } 67 } 68 } 69 70 function render(value) { 71 var formattedValue = settings.formatter.call(self, value, settings); 72 $self.html(formattedValue); 73 } 74 }); 75}; 76$.fn.countTo.defaults = { 77 from: 0, //æ°åå¼å§çå¼ 78 to: 0, //æ°åç»æçå¼ 79 speed: 1000, //设置æ¥é¿çæ¶é´ 80 refreshInterval: 100, //éé´å¼ 81 decimals: 0, //æ¾ç¤ºå°ä½æ° 82 formatter: formatter, //渲æä¹åæ ¼å¼å 83 onUpdate: null, //æ¯æ¬¡æ´æ°åçåè°æ¹æ³ 84 onComplete: null //å®ææ´æ°çåè°æ¹æ³ 85}; 86 87function formatter(value, settings) { 88 return value.toFixed(settings.decimals); 89} 90//èªå®ä¹æ ¼å¼ 91$('#count-number').data('countToOptions', { 92 formmatter: function(value, options) { 93 return value.toFixed(options.decimals).replace(/\B(?=(?:\d{3})+(?!\d))/g, ','); 94 } 95}); 96//宿¶å¨ 97$('.timer').each(count); 98 99function count(options) { 100 var $this = $(this); 101 options = $.extend({}, options || {}, $this.data('countToOptions') || {}); 102 $this.countTo(options); 103};
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.