diff --git a/index.html b/index.html
index 96ab083..06fff2d 100644
--- a/index.html
+++ b/index.html
@@ -322,12 +322,14 @@
onScroll(); window.addEventListener('scroll', onScroll, { passive: true });
}
- // count the proof numbers up when they scroll into view
+ // count the proof numbers up when the stats block is discovered (after its reveal,
+ // so the increment is actually on-screen — not hidden behind the fade-in)
+ var statsEl = document.querySelector('.stats');
var counters = [].slice.call(document.querySelectorAll('[data-count]'));
- if (counters.length && !rm && 'IntersectionObserver' in window) {
+ if (statsEl && counters.length && 'IntersectionObserver' in window) {
counters.forEach(function (c) { c.textContent = '0'; });
var run = function (el) {
- var to = parseInt(el.getAttribute('data-count'), 10), dur = 1500, t0 = null;
+ var to = parseInt(el.getAttribute('data-count'), 10), dur = 1600, t0 = null;
var tick = function (ts) {
if (!t0) t0 = ts;
var p = Math.min((ts - t0) / dur, 1), e = 1 - Math.pow(1 - p, 3);
@@ -336,10 +338,15 @@
};
requestAnimationFrame(tick);
};
+ var started = false;
var nio = new IntersectionObserver(function (es) {
- es.forEach(function (e) { if (e.isIntersecting) { run(e.target); nio.unobserve(e.target); } });
- }, { threshold: 0.5 });
- counters.forEach(function (c) { nio.observe(c); });
+ es.forEach(function (e) {
+ if (e.isIntersecting && !started) { started = true; counters.forEach(run); nio.disconnect(); }
+ });
+ }, { threshold: 0.6 });
+ nio.observe(statsEl);
+ } else {
+ counters.forEach(function (c) { c.textContent = c.getAttribute('data-count'); });
}
})();