diff options
Diffstat (limited to 'assets/js')
| -rw-r--r-- | assets/js/hero-glitch.js | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/assets/js/hero-glitch.js b/assets/js/hero-glitch.js new file mode 100644 index 0000000..1b39b2f --- /dev/null +++ b/assets/js/hero-glitch.js @@ -0,0 +1,12 @@ +(function () { + var name = document.querySelector('.hero-name'); + if (!name) return; + if (window.matchMedia('(prefers-reduced-motion: reduce)').matches) return; + + function glitch() { + name.classList.add('is-glitching'); + setTimeout(function () { name.classList.remove('is-glitching'); }, 500); + setTimeout(glitch, 4000 + Math.random() * 7000); + } + setTimeout(glitch, 3500); +})(); |
