X-Git-Url: https://git.r.bdr.sh/rbdr/r.bdr.sh/blobdiff_plain/23398f9ac73be679f9487a10ce4e81562fb45102..40af835cd5c95e4de38fe9b8e1d0b4150f4a32e3:/js/animation.js diff --git a/js/animation.js b/js/animation.js index ecf5e43..f2f998a 100644 --- a/js/animation.js +++ b/js/animation.js @@ -1,5 +1,7 @@ (function () { + if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) 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) @@ -84,7 +87,7 @@ } function frm(t) { - requestAnimationFrame(frm) + if (Z) requestAnimationFrame(frm) var dt = t - l @@ -101,6 +104,7 @@ } } + canvas.addEventListener('click', () => (Z ? Z=0:(Z=1&&frm()))) frm() } )()