From: Ruben Beltran del Rio Date: Mon, 9 Sep 2024 19:59:46 +0000 (+0200) Subject: Update animation X-Git-Url: https://git.r.bdr.sh/rbdr/r.bdr.sh/commitdiff_plain/b8bcdb6d9055236cec6271eff61f6bfc4ecc3faa?ds=inline Update animation --- diff --git a/js/animation.js b/js/animation.js index ecf5e43..ee43c54 100644 --- a/js/animation.js +++ b/js/animation.js @@ -1,5 +1,7 @@ (function () { + if (window.matchMedia(`(prefers-reduced-motion: reduce)`).matches === true) return; + var K = document.querySelector('canvas'), { random: R, PI, cos: C, sin: S, atan2: A } = Math, id = p => p, @@ -15,7 +17,8 @@ a: R() * 2 * PI, c: r(100) })), H = [sqr, crc, hrt, chs, lch], P = [id, spn(5), spn(15)], - draw = H[r(H.length)], pos = P[r(P.length)] + draw = H[r(H.length)], pos = P[r(P.length)], + Z = 1 function r(x) { return ~~(R() * x) @@ -83,8 +86,10 @@ i.c = (i.c + 2) % 101 } + canvas.addEventListener('click', () => {Z ? Z=0:(Z=1;frm())}) + function frm(t) { - requestAnimationFrame(frm) + if (Z) requestAnimationFrame(frm) var dt = t - l