Skip to content

Commit f93e2bc

Browse files
committed
fix: 增加对减少运动偏好的支持以优化视图过渡
1 parent a25ad30 commit f93e2bc

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

.vitepress/theme/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,14 @@ export default {
3535
const isChromium =
3636
navigator.userAgent.includes("Chrome") ||
3737
navigator.userAgent.includes("Chromium");
38-
if (!isChromium || !document.startViewTransition) {
38+
const prefersReducedMotion = window.matchMedia(
39+
"(prefers-reduced-motion: reduce)",
40+
).matches;
41+
if (
42+
!isChromium ||
43+
prefersReducedMotion ||
44+
!document.startViewTransition
45+
) {
3946
return;
4047
}
4148
router.onBeforeRouteChange = (to) => {

0 commit comments

Comments
 (0)