Commit 51538dbc authored by Zachary Dunn's avatar Zachary Dunn

Check prefers-reduced-motion media query before scroll-to-top animation

parent 9ffc4505
......@@ -84,9 +84,9 @@
let topAnchor = document.querySelector('#top');
let scrollUpBtn = document.querySelector('.back-to-top');
if (scrollUpBtn.scrollIntoView) {
let scrollOpts = { behavior: 'smooth' };
const behavior = window.matchMedia('(prefers-reduced-motion: reduce)').matches ? 'auto' : 'smooth';
scrollUpBtn.removeAttribute('href');
scrollUpBtn.addEventListener('click', event => topAnchor.scrollIntoView(scrollOpts));
scrollUpBtn.addEventListener('click', event => topAnchor.scrollIntoView({ behavior }));
}
let progressBar = document.querySelector('#progress-bar');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment