mirror of
https://github.com/Wonderfall/hugo-WonderMod.git
synced 2024-11-25 12:01:37 +01:00
Do not smooth scrollIntoView
if user has it preferred https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion
This commit is contained in:
parent
dd83560010
commit
b6a308d331
@ -38,9 +38,13 @@
|
|||||||
anchor.addEventListener("click", function (e) {
|
anchor.addEventListener("click", function (e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
var id = this.getAttribute("href").substr(1);
|
var id = this.getAttribute("href").substr(1);
|
||||||
|
if (!window.matchMedia('(prefers-reduced-motion: reduce)').matches) {
|
||||||
document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView({
|
document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView({
|
||||||
behavior: "smooth"
|
behavior: "smooth"
|
||||||
});
|
});
|
||||||
|
} else {
|
||||||
|
document.querySelector(`[id='${decodeURIComponent(id)}']`).scrollIntoView();
|
||||||
|
}
|
||||||
if (id === "top") {
|
if (id === "top") {
|
||||||
history.replaceState(null, null, " ");
|
history.replaceState(null, null, " ");
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user