Skip to content

Commit d290875

Browse files
authored
Cancel animation when a custom Timeline is used (facebook#35567)
Follow up to facebook#35559. The clean up function of the custom timeline doesn't necessarily clean up the animation. Just the timeline's internal state. This affects Firefox which doesn't support ScrollTimeline so uses the polyfill's custom timeline.
1 parent d343c39 commit d290875

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ export default function Page({url, navigate}) {
150150
const cleanup1 = timeline.animate(animation1);
151151
const cleanup2 = timeline.animate(animation2);
152152
return () => {
153+
animation1.cancel();
154+
animation2.cancel();
153155
cleanup1();
154156
cleanup2();
155157
};

packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2525,6 +2525,7 @@ function animateGesture(
25252525
delay: reverse ? rangeEnd : rangeStart,
25262526
duration: reverse ? rangeStart - rangeEnd : rangeEnd - rangeStart,
25272527
});
2528+
viewTransitionAnimations.push(animation);
25282529
// Let the custom timeline take control of driving the animation.
25292530
const cleanup = timeline.animate(animation);
25302531
if (cleanup) {

0 commit comments

Comments
 (0)