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