mirror of
https://github.com/vinta/awesome-python.git
synced 2026-05-14 00:47:14 +00:00
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:
parent
db83de1b42
commit
d58c915a0b
1 changed files with 2 additions and 1 deletions
|
|
@ -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();
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue