Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great fix! This properly tracks the animation for cleanup.

Original file line number Diff line number Diff line change
Expand Up @@ -2372,6 +2372,7 @@ function animateGesture(
targetElement: Element,
pseudoElement: string,
timeline: GestureTimeline,
viewTransitionAnimations: Array<Animation>,
customTimelineCleanup: Array<() => void>,
rangeStart: number,
rangeEnd: number,
Expand Down Expand Up @@ -2464,7 +2465,7 @@ function animateGesture(
if (timeline instanceof AnimationTimeline) {
// Native Timeline
// $FlowFixMe[incompatible-call]
targetElement.animate(keyframes, {
const animation = targetElement.animate(keyframes, {
pseudoElement: pseudoElement,
// Set the timeline to the current gesture timeline to drive the updates.
timeline: timeline,
Expand All @@ -2482,6 +2483,7 @@ function animateGesture(
rangeStart: (reverse ? rangeEnd : rangeStart) + '%',
rangeEnd: (reverse ? rangeStart : rangeEnd) + '%',
});
viewTransitionAnimations.push(animation);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good addition - this ensures the animation is tracked for proper cleanup.

} else {
// Custom Timeline
// $FlowFixMe[incompatible-call]
Expand Down Expand Up @@ -2554,8 +2556,10 @@ export function startGestureTransition(
// $FlowFixMe
const pseudoElement: ?string = effect.pseudoElement;
if (pseudoElement == null) {
} else if (pseudoElement.startsWith('::view-transition')) {
viewTransitionAnimations.push(animations[i]);
} else if (
pseudoElement.startsWith('::view-transition') &&
effect.target === documentElement
) {
const timing = effect.getTiming();
const duration =
// $FlowFixMe[prop-missing]
Expand Down Expand Up @@ -2648,6 +2652,7 @@ export function startGestureTransition(
effect.target,
pseudoElement,
timeline,
viewTransitionAnimations,
customTimelineCleanup,
adjustedRangeStart,
adjustedRangeEnd,
Expand Down Expand Up @@ -2675,6 +2680,7 @@ export function startGestureTransition(
effect.target,
pseudoElementName,
timeline,
viewTransitionAnimations,
customTimelineCleanup,
rangeStart,
rangeEnd,
Expand All @@ -2696,6 +2702,7 @@ export function startGestureTransition(
duration: 1,
});
blockingAnim.pause();
viewTransitionAnimations.push(blockingAnim);
animateCallback();
};
// In Chrome, "new" animations are not ready in the ready callback. We have to wait
Expand Down
Loading