PageSourceSearch

https://aspireyouth.com/wp-content/themes/levelup/assets/vendor/countup.js?ver=2.0.11

js aspireyouth.com collected 2026-10-02 00:16:15 UTC 8,568 bytes, 227 lines download raw bytes

1
2(function (global, factory) {
3    typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
4        typeof define === 'function' && define.amd ? define(factory) :
5            global.CountUp = factory()
6}(this, function () {
7
8    'use strict';
9
10    /*
11     countUp.js
12     by @inorganik
13     */
14
15    // target = id of html element or var of previously selected html element where counting occurs
16    // startVal = the value you want to begin at
17    // endVal = the value you want to arrive at
18    // decimals = number of decimal places, default 0
19    // duration = duration of animation in seconds, default 2
20    // options = optional object of options (see below)
21
22    var CountUp = function CountUp(target, startVal, endVal, decimals, duration, options) {
23
24        // make sure requestAnimationFrame and cancelAnimationFrame are defined
25        // polyfill for browsers without native support
26        // by Opera engineer Erik Möller
27        var lastTime = 0;
28        var vendors = ['webkit', 'moz', 'ms', 'o'];
29        for(var x = 0; x < vendors.length && !window.requestAnimationFrame; ++x) {
30            window.requestAnimationFrame = window[vendors[x]+'RequestAnimationFrame'];
31            window.cancelAnimationFrame =
32                window[vendors[x]+'CancelAnimationFrame'] || window[vendors[x]+'CancelRequestAnimationFrame'];
33        }
34        if (!window.requestAnimationFrame) {
35            window.requestAnimationFrame = function(callback, element) {
36                var currTime = new Date().getTime();
37                var timeToCall = Math.max(0, 16 - (currTime - lastTime));
38                var id = window.setTimeout(function() { callback(currTime + timeToCall); },
39                    timeToCall);
40                lastTime = currTime + timeToCall;
41                return id;
42            }
43        }
44        if (!window.cancelAnimationFrame) {
45            window.cancelAnimationFrame = function(id) {
46                clearTimeout(id);
47            }
48        }
49
50        // default options
51        this.options = {
52            useEasing : true, // toggle easing
53            useGrouping : true, // 1,000,000 vs 1000000
54            separator : ',', // character to use as a separator
55            decimal : '.' // character to use as a decimal
56        }
57
58        // extend default options with input object
59        for (var key in options) {
60            if (options.hasOwnProperty(key)) {
61                this.options[key] = options[key];
62            }
63        }
64
65        if (this.options.separator == '') this.options.useGrouping = false;
66        if (this.options.prefix == null) this.options.prefix = '';
67        if (this.options.suffix == null) this.options.suffix = '';
68
69        var self = this;
70
71        this.d = (typeof target === 'string') ? document.getElementById(target) : target;
72        this.startVal = Number(startVal);
73        this.endVal = Number(endVal);
74        this.countDown = (this.startVal > this.endVal);
75        this.startTime = null;
76        this.timestamp = null;
77        this.remaining = null;
78        this.frameVal = this.startVal;
79        this.rAF = null;
80        this.decimals = Math.max(0, decimals || 0);
81        this.dec = Math.pow(10, this.decimals);
82        this.duration = duration * 1000 || 2000;
83
84        this.version = function () { return '1.5.0' }
85
86        // Print value to target
87        this.printValue = function(value) {
88            var result = (!isNaN(value)) ? self.formatNumber(value) : '--';
89            if (self.d.tagName == 'INPUT') {
90                this.d.value = result;
91            }
92            else if (self.d.tagName == 'text') {
93                this.d.textContent = result;
94            }
95            else {
96                this.d.innerHTML = result;
97            }
98        }
99
100        // Robert Penner's easeOutExpo
101        this.easeOutExpo = function(t, b, c, d) {
102            return c * (-Math.pow(2, -10 * t / d) + 1) * 1024 / 1023 + b;
103        }
104        this.count = function(timestamp) {
105
106            if (self.startTime === null) self.startTime = timestamp;
107
108            self.timestamp = timestamp;
109
110            var progress = timestamp - self.startTime;
111            self.remaining = self.duration - progress;
112
113            // to ease or not to ease
114            if (self.options.useEasing) {
115                if (self.countDown) {
116                    var i = self.easeOutExpo(progress, 0, self.startVal - self.endVal, self.duration);
117                    self.frameVal = self.startVal - i;
118                } else {
119                    self.frameVal = self.easeOutExpo(progress, self.startVal, self.endVal - self.startVal, self.duration);
120                }
121            } else {
122                if (self.countDown) {
123                    var i = (self.startVal - self.endVal) * (progress / self.duration);
124                    self.frameVal = self.startVal - i;
125                } else {
126                    self.frameVal = self.startVal + (self.endVal - self.startVal) * (progress / self.duration);
127                }
128            }
129
130            // don't go past endVal since progress can exceed duration in the last frame
131            if (self.countDown) {
132                self.frameVal = (self.frameVal < self.endVal) ? self.endVal : self.frameVal;
133            } else {
134                self.frameVal = (self.frameVal > self.endVal) ? self.endVal : self.frameVal;
135            }
136
137            // decimal
138            self.frameVal = Math.round(self.frameVal*self.dec)/self.dec;
139
140            // format and print value
141            self.printValue(self.frameVal);
142
143            // whether to continue
144            if (progress < self.duration) {
145                self.rAF = requestAnimationFrame(self.count);
146            } else {
147                if (self.callback != null) self.callback();
148            }
149        }
150        // start your animation
151        this.start = function(callback) {
152            self.callback = callback;
153            // make sure values are valid
154            if (!isNaN(self.endVal) && !isNaN(self.startVal)) {
155                self.rAF = requestAnimationFrame(self.count);
156            } else {
157                console.log('countUp error: startVal or endVal is not a number');
158                self.printValue();
159            }
160            return false;
161        }
162        // toggles pause/resume animation
163        this.pauseResume = function() {
164            if (!self.paused) {
165                self.paused = true;
166                cancelAnimationFrame(self.rAF);
167            } else {
168                self.paused = false;
169                self.startTime = null;
170                self.duration = self.remaining;
171                self.startVal = self.frameVal;
172                requestAnimationFrame(self.count);
173            }
174        }
175        // deprecated - use pauseResume()
176        this.stop = function() {
177            cancelAnimationFrame(self.rAF);
178        }
179        // deprecated - use pauseResume()
180        this.resume = function() {
181            self.stop();
182            self.startTime = null;
183            self.duration = self.remaining;
184            self.startVal = self.frameVal;
185            requestAnimationFrame(self.count);
186        }
187        // reset to startVal so animation can be run again
188        this.reset = function() {
189            self.paused = false;
190            self.startTime = null;
191            self.startVal = startVal;
192            cancelAnimationFrame(self.rAF);
193            self.printValue(self.startVal);
194        }
195        // pass a new endVal and start animation
196        this.update = function (newEndVal) {
197            cancelAnimationFrame(self.rAF);
198            self.paused = false;
199            self.startTime = null;
200            self.startVal = self.frameVal;
201            self.endVal = Number(newEndVal);
202            self.countDown = (self.startVal > self.endVal);
203            self.rAF = requestAnimationFrame(self.count);
204        }
205        this.formatNumber = function(nStr) {
206            nStr = nStr.toFixed(self.decimals);
207            nStr += '';
208            var x, x1, x2, rgx;
209            x = nStr.split('.');
210            x1 = x[0];
211            x2 = x.length > 1 ? self.options.decimal + x[1] : '';
212            rgx = /(\d+)(\d{3})/;
213            if (self.options.useGrouping) {
214                while (rgx.test(x1)) {
215                    x1 = x1.replace(rgx, '$1' + self.options.separator + '$2');
216                }
217            }
218            return self.options.prefix + x1 + x2 + self.options.suffix;
219        }
220
221        // format startVal on initialization
222        self.printValue(self.startVal);
223    }
224
225    return CountUp;
226
227}));

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.