summaryrefslogtreecommitdiffstats
path: root/assets/js/hero-glitch.js
blob: 1b39b2f49528c0d82a7724a71e2aa21f9d9d71c0 (plain)
1
2
3
4
5
6
7
8
9
10
11
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);
})();