Skip to content

Commit 71a7691

Browse files
authored
Respect prefers-reduced-motion (#1409)
* Respect prefers-reduced-motion * Added test for reduced motion
1 parent bea2f48 commit 71a7691

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/core/drive/page_snapshot.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ export class PageSnapshot extends Snapshot {
7171
}
7272

7373
get prefersViewTransitions() {
74-
return this.headSnapshot.getMetaValue("view-transition") === "same-origin"
74+
return this.headSnapshot.getMetaValue("view-transition") === "same-origin" && !window.matchMedia("(prefers-reduced-motion: reduce)").matches
7575
}
7676

7777
get shouldMorphPage() {

src/tests/functional/drive_view_transition_tests.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ test("navigating triggers the view transition", async ({ page }) => {
2121
assert.isTrue(called)
2222
})
2323

24+
test("navigating does not trigger a view transition when prefers reduced motion is reduce", async ({ page }) => {
25+
await page.emulateMedia({ reducedMotion: 'reduce' })
26+
await page.locator("#go-right").click()
27+
await nextBody(page)
28+
29+
const called = await page.evaluate(`window.startViewTransitionCalled`)
30+
assert.isUndefined(called)
31+
})
32+
2433
test("navigating does not trigger a view transition when meta tag not present", async ({ page }) => {
2534
await page.locator("#go-other").click()
2635
await nextBody(page)

0 commit comments

Comments
 (0)