Skip to content

Commit 45ca295

Browse files
committed
Use polyfill from "animation-timelines" package
1 parent 8a1dec9 commit 45ca295

File tree

3 files changed

+21
-8
lines changed

3 files changed

+21
-8
lines changed

fixtures/view-transition/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"ignore-styles": "^5.0.1",
1515
"react": "^19.0.0",
1616
"react-dom": "^19.0.0",
17-
"animation-timelines": "^0.0.1"
17+
"animation-timelines": "^0.0.2"
1818
},
1919
"eslintConfig": {
2020
"extends": [

fixtures/view-transition/src/components/SwipeRecognizer.js

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import React, {
55
unstable_startGestureTransition as startGestureTransition,
66
} from 'react';
77

8+
import ScrollTimelinePolyfill from 'animation-timelines/scroll-timeline';
9+
810
// Example of a Component that can recognize swipe gestures using a ScrollTimeline
911
// without scrolling its own content. Allowing it to be used as an inert gesture
1012
// recognizer to drive a View Transition.
@@ -25,14 +27,20 @@ export default function SwipeRecognizer({
2527
if (activeGesture.current !== null) {
2628
return;
2729
}
28-
if (typeof ScrollTimeline !== 'function') {
29-
return;
30+
31+
let scrollTimeline;
32+
if (typeof ScrollTimeline === 'function') {
33+
// eslint-disable-next-line no-undef
34+
scrollTimeline = new ScrollTimeline({
35+
source: scrollRef.current,
36+
axis: axis,
37+
});
38+
} else {
39+
scrollTimeline = new ScrollTimelinePolyfill({
40+
source: scrollRef.current,
41+
axis: axis,
42+
});
3043
}
31-
// eslint-disable-next-line no-undef
32-
const scrollTimeline = new ScrollTimeline({
33-
source: scrollRef.current,
34-
axis: axis,
35-
});
3644
activeGesture.current = startGestureTransition(
3745
scrollTimeline,
3846
() => {

fixtures/view-transition/yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2427,6 +2427,11 @@ ajv@^8.0.0, ajv@^8.6.0, ajv@^8.9.0:
24272427
json-schema-traverse "^1.0.0"
24282428
require-from-string "^2.0.2"
24292429

2430+
animation-timelines@^0.0.2:
2431+
version "0.0.2"
2432+
resolved "https://registry.yarnpkg.com/animation-timelines/-/animation-timelines-0.0.2.tgz#b31633ab5abbd105c431a5d2c19786f58c7c3576"
2433+
integrity sha512-loYiP+QYYVz7LqL5LzESJWqlqlPihqbOzxMukf6BagwtSEpx+fWscxt3ZwD+dIKyFP+yYpyp3IwDyAMxm4k89g==
2434+
24302435
ansi-escapes@^4.2.1, ansi-escapes@^4.3.1:
24312436
version "4.3.2"
24322437
resolved "https://registry.yarnpkg.com/ansi-escapes/-/ansi-escapes-4.3.2.tgz#6b2291d1db7d98b6521d5f1efa42d0f3a9feb65e"

0 commit comments

Comments
 (0)