diff options
| author | Aditya Telange <21258296+adityatelange@users.noreply.github.com> | 2021-01-13 23:19:35 +0530 |
|---|---|---|
| committer | Aditya Telange <21258296+adityatelange@users.noreply.github.com> | 2021-01-13 23:19:35 +0530 |
| commit | b6a308d331d7ef2f59599203eb3b59890baef8ac (patch) | |
| tree | 3a616ec0130f31733ebb3c15fe6182a7e6505dfd /layouts | |
| parent | dd835600104d051ebaf591658939ab131c5ff494 (diff) | |
Do not smooth scrollIntoView
if user has it preferred
https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/partials/footer.html | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/layouts/partials/footer.html b/layouts/partials/footer.html index 4623b3f..f5ca45d 100644 --- a/layouts/partials/footer.html +++ b/layouts/partials/footer.html @@ -38,9 +38,13 @@ anchor.addEventListener("click", function (e) { e.preventDefault(); var id = this.getAttribute("href").substr(1); - document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView({ - behavior: "smooth" - }); + if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) { + document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView({ + behavior: "smooth" + }); + } else { + document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView(); + } if (id === "top") { history.replaceState(null, null, " "); } else { |
