fix(shared-transition): race condition with interactive updates (#10312)

This commit is contained in:
Nathan Walker
2023-06-13 10:13:33 -07:00
committed by GitHub
parent ab5fa941bc
commit 25cc49d4f4

View File

@ -526,7 +526,8 @@ export class SharedTransitionHelper {
} }
static interactiveUpdate(state: SharedTransitionState, interactiveState: PlatformTransitionInteractiveState, type: TransitionNavigationType, percent: number) { static interactiveUpdate(state: SharedTransitionState, interactiveState: PlatformTransitionInteractiveState, type: TransitionNavigationType, percent: number) {
if (!interactiveState?.added) { if (interactiveState) {
if (!interactiveState.added) {
interactiveState.added = true; interactiveState.added = true;
for (const p of state.instance.sharedElements.presented) { for (const p of state.instance.sharedElements.presented) {
p.view.opacity = 0; p.view.opacity = 0;
@ -550,6 +551,7 @@ export class SharedTransitionHelper {
state.instance.presented.view.frame = CGRectMake(startFrame.x, startFrame.y, state.instance.presented.view.bounds.size.width, state.instance.presented.view.bounds.size.height); state.instance.presented.view.frame = CGRectMake(startFrame.x, startFrame.y, state.instance.presented.view.bounds.size.width, state.instance.presented.view.bounds.size.height);
}); });
} }
interactiveState.propertyAnimator.fractionComplete = percent; interactiveState.propertyAnimator.fractionComplete = percent;
SharedTransition.notifyEvent(SharedTransition.interactiveUpdateEvent, { SharedTransition.notifyEvent(SharedTransition.interactiveUpdateEvent, {
id: state?.instance?.id, id: state?.instance?.id,
@ -557,6 +559,7 @@ export class SharedTransitionHelper {
percent, percent,
}); });
} }
}
static interactiveCancel(state: SharedTransitionState, interactiveState: PlatformTransitionInteractiveState, type: TransitionNavigationType) { static interactiveCancel(state: SharedTransitionState, interactiveState: PlatformTransitionInteractiveState, type: TransitionNavigationType) {
if (state?.instance && interactiveState?.added && interactiveState?.propertyAnimator) { if (state?.instance && interactiveState?.added && interactiveState?.propertyAnimator) {