fix(a11y): respect prefers-reduced-motion in back-to-top scroll

Swap the hardcoded 'smooth' scroll behavior for a runtime check so users
who have enabled reduced-motion in their OS get instant (auto) scrolling
instead of the animated kind.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Vinta Chen
2026-03-24 12:37:36 +08:00
parent db83de1b42
commit d58c915a0b

View File

@@ -394,7 +394,8 @@ if (backToTop) {
backToTop.addEventListener("click", function () {
const target = searchInput || resultsSection;
if (!target) return;
target.scrollIntoView({ behavior: "smooth", block: "center" });
var motion = window.matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
target.scrollIntoView({ behavior: motion, block: "center" });
if (searchInput) searchInput.focus();
});