mirror of
https://github.com/vinta/awesome-python.git
synced 2026-05-24 06:36:06 +08: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:
@@ -394,7 +394,8 @@ if (backToTop) {
|
|||||||
backToTop.addEventListener("click", function () {
|
backToTop.addEventListener("click", function () {
|
||||||
const target = searchInput || resultsSection;
|
const target = searchInput || resultsSection;
|
||||||
if (!target) return;
|
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();
|
if (searchInput) searchInput.focus();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user