Download web/js/count-up.js from githubtailscaleduplicity342/RL-Explorer: direct link, hf CLI and curl.
- Browser
- Download file 686 Bytes
-
https://huggingface.co/spaces/githubtailscaleduplicity342/RL-Explorer/resolve/main/web/js/count-up.js
- Command line
-
hf download hf://spaces/githubtailscaleduplicity342/RL-Explorer/web/js/count-up.js
-
curl -L -o count-up.js https://huggingface.co/spaces/githubtailscaleduplicity342/RL-Explorer/resolve/main/web/js/count-up.js
686 Bytes
| // The accessible label always holds the final count. Only the visual number | |
| // animates, once per change, and detached views stop requesting frames. | |
| export function countUp(node, target, format, from = 0) { | |
| node.textContent = format(target); | |
| if (from === target || matchMedia("(prefers-reduced-motion: reduce)").matches) return; | |
| node.textContent = format(from); | |
| const start = performance.now(); | |
| const frame = (now) => { | |
| if (!node.isConnected) return; | |
| const t = Math.min(1, (now - start) / 750); | |
| node.textContent = format(Math.round(from + (target - from) * (1 - (1 - t) ** 3))); | |
| if (t < 1) requestAnimationFrame(frame); | |
| }; | |
| requestAnimationFrame(frame); | |
| } | |