PageSourceSearch

https://timxon.com/webfile/en/js/number-about.js

js timxon.com collected 2026-10-02 06:40:32 UTC 3,106 bytes, 99 lines download raw bytes

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.