Skip to main content

Published by Michael Spellacy (Spell) on

Repost of http://scottohara.me/note/2019/03/27/reduced-sticky.html

Nice post here about “sticky” navigations and prefers-reduced-motion, which I have also been using more and more often. In addition to CSS, don’t forget that you can do it in JavaScript, too.

const mediaQuery = window.matchMedia("(prefers-reduced-motion: reduce)");

mediaQuery.addEventListener("change", () => {

  console.log(mediaQuery.media, mediaQuery.matches);

  // Stop JavaScript animation

});