Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d58c915

Browse files
vintaclaude
andcommitted
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 <[email protected]>
1 parent db83de1 commit d58c915

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

website/static/main.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,8 @@ if (backToTop) {
394394
backToTop.addEventListener("click", function () {
395395
const target = searchInput || resultsSection;
396396
if (!target) return;
397-
target.scrollIntoView({ behavior: "smooth", block: "center" });
397+
var motion = window.matchMedia("(prefers-reduced-motion: reduce)").matches ? "auto" : "smooth";
398+
target.scrollIntoView({ behavior: motion, block: "center" });
398399
if (searchInput) searchInput.focus();
399400
});
400401

0 commit comments

Comments
 (0)