(el, fn)
| 63 | |
| 64 | // ── Lazy: only fire when the element scrolls into view ────────────────── |
| 65 | function whenInView(el, fn) { |
| 66 | if (!el) return; |
| 67 | if (REDUCED) { |
| 68 | fn(); |
| 69 | return; |
| 70 | } |
| 71 | const obs = new IntersectionObserver( |
| 72 | (entries) => { |
| 73 | entries.forEach((e) => { |
| 74 | if (e.isIntersecting) { |
| 75 | obs.disconnect(); |
| 76 | fn(); |
| 77 | } |
| 78 | }); |
| 79 | }, |
| 80 | { rootMargin: "0px 0px -10% 0px" } |
| 81 | ); |
| 82 | obs.observe(el); |
| 83 | } |
| 84 | |
| 85 | // Helper: build an SVG element from a string template. |
| 86 | function svgEl(tag, attrs) { |
no outgoing calls
no test coverage detected