1export default class Count { 2 constructor($el) { 3 this.$el = $el; 4 this.init(); 5 } 6 init() { 7 this.target = Number(this.$el.innerText || 0); 8 this.delay = Number(this.$el.dataset.delay) || 0; 9 this.once = this.$el.dataset.once !== undefined; 10 this.pad = this.$el.dataset.pad !== undefined; 11 this.current = 0; 12 this.observer = new IntersectionObserver(([entry]) => { 13 if (entry.isIntersecting) { 14 if (this.timeout) { 15 clearTimeout(this.timeout); 16 } 17 if (this.delay) { 18 this.timeout = setTimeout(() => { 19 this.play(); 20 }, this.delay); 21 }else { 22 this.play(); 23 } 24 } else { 25 this.reset(); 26 } 27 }); 28 this.observer.observe(this.$el); 29 } 30 play() { 31 if(this.once) { 32 this.observer.unobserve(this.$el); 33 } 34 const toFixed = this.target % 1 !== 0 ? 1 : 0; 35 const data = {value: this.current}; 36 gsap.to(data, { 37 value: this.target, 38 duration: 2, 39 ease: 'circ.inOut', 40 onUpdate: () => { 41 let c = toFixed ? data.value.toFixed(toFixed) : Math.round(data.value); 42 if (this.pad) { 43 c = c.toString().padStart(this.target.toString().length, '0'); 44 } 45 this.current = c; 46 this.update(); 47 } 48 }); 49 } 50 reset() { 51 this.current = 0; 52 this.update(); 53 } 54 update() { 55 this.$el.innerText = this.current; 56 } 57} 58const $counts = document.querySelectorAll('.count'); 59$counts.forEach($count => new Count($count));
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.