Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 25cc49d

Browse filesBrowse files
authored
fix(shared-transition): race condition with interactive updates (#10312)
1 parent ab5fa94 commit 25cc49d
Copy full SHA for 25cc49d

File tree

1 file changed

+28
-25
lines changed
Filter options

1 file changed

+28
-25
lines changed

‎packages/core/ui/transition/shared-transition-helper.ios.ts

Copy file name to clipboardExpand all lines: packages/core/ui/transition/shared-transition-helper.ios.ts
+28-25Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -526,36 +526,39 @@ export class SharedTransitionHelper {
526526
}
527527

528528
static interactiveUpdate(state: SharedTransitionState, interactiveState: PlatformTransitionInteractiveState, type: TransitionNavigationType, percent: number) {
529-
if (!interactiveState?.added) {
530-
interactiveState.added = true;
531-
for (const p of state.instance.sharedElements.presented) {
532-
p.view.opacity = 0;
533-
}
534-
for (const p of state.instance.sharedElements.presenting) {
535-
p.snapshot.alpha = p.endOpacity;
536-
interactiveState.transitionContext.containerView.addSubview(p.snapshot);
537-
}
529+
if (interactiveState) {
530+
if (!interactiveState.added) {
531+
interactiveState.added = true;
532+
for (const p of state.instance.sharedElements.presented) {
533+
p.view.opacity = 0;
534+
}
535+
for (const p of state.instance.sharedElements.presenting) {
536+
p.snapshot.alpha = p.endOpacity;
537+
interactiveState.transitionContext.containerView.addSubview(p.snapshot);
538+
}
538539

539-
const pageStart = state.pageStart;
540+
const pageStart = state.pageStart;
540541

541-
const startFrame = getRectFromProps(pageStart, getPageStartDefaultsForType(type));
542-
interactiveState.propertyAnimator = UIViewPropertyAnimator.alloc().initWithDurationDampingRatioAnimations(1, 1, () => {
543-
for (const p of state.instance.sharedElements.presenting) {
544-
p.snapshot.frame = p.startFrame;
545-
iOSUtils.copyLayerProperties(p.snapshot, p.view.ios, p.propertiesToMatch as any);
542+
const startFrame = getRectFromProps(pageStart, getPageStartDefaultsForType(type));
543+
interactiveState.propertyAnimator = UIViewPropertyAnimator.alloc().initWithDurationDampingRatioAnimations(1, 1, () => {
544+
for (const p of state.instance.sharedElements.presenting) {
545+
p.snapshot.frame = p.startFrame;
546+
iOSUtils.copyLayerProperties(p.snapshot, p.view.ios, p.propertiesToMatch as any);
546547

547-
p.snapshot.alpha = 1;
548-
}
549-
state.instance.presented.view.alpha = isNumber(state.pageReturn?.opacity) ? state.pageReturn?.opacity : 0;
550-
state.instance.presented.view.frame = CGRectMake(startFrame.x, startFrame.y, state.instance.presented.view.bounds.size.width, state.instance.presented.view.bounds.size.height);
548+
p.snapshot.alpha = 1;
549+
}
550+
state.instance.presented.view.alpha = isNumber(state.pageReturn?.opacity) ? state.pageReturn?.opacity : 0;
551+
state.instance.presented.view.frame = CGRectMake(startFrame.x, startFrame.y, state.instance.presented.view.bounds.size.width, state.instance.presented.view.bounds.size.height);
552+
});
553+
}
554+
555+
interactiveState.propertyAnimator.fractionComplete = percent;
556+
SharedTransition.notifyEvent(SharedTransition.interactiveUpdateEvent, {
557+
id: state?.instance?.id,
558+
type,
559+
percent,
551560
});
552561
}
553-
interactiveState.propertyAnimator.fractionComplete = percent;
554-
SharedTransition.notifyEvent(SharedTransition.interactiveUpdateEvent, {
555-
id: state?.instance?.id,
556-
type,
557-
percent,
558-
});
559562
}
560563

561564
static interactiveCancel(state: SharedTransitionState, interactiveState: PlatformTransitionInteractiveState, type: TransitionNavigationType) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.