Skip to content

Commit fac970e

Browse files
authored
fix(android): back navigation on app suspend/resume (NativeScript#6489)
1 parent 2933a9a commit fac970e

File tree

1 file changed

+21
-10
lines changed

1 file changed

+21
-10
lines changed

tns-core-modules/ui/frame/frame.android.ts

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ import { createViewFromEntry } from "../builder";
2525
export * from "./frame-common";
2626

2727
interface AnimatorState {
28-
enterAnimator: android.animation.Animator;
29-
exitAnimator: android.animation.Animator;
30-
popEnterAnimator: android.animation.Animator;
31-
popExitAnimator: android.animation.Animator;
28+
enterAnimator: any;
29+
exitAnimator: any;
30+
popEnterAnimator: any;
31+
popExitAnimator: any;
3232
transitionName: string;
3333
}
3434

@@ -306,10 +306,8 @@ export class Frame extends FrameBase {
306306
// restore cached animation settings if we just completed simulated first navigation (no animation)
307307
if (this._cachedAnimatorState) {
308308
restoreAnimatorState(this._currentEntry, this._cachedAnimatorState);
309-
310309
this._cachedAnimatorState = null;
311310
}
312-
313311
}
314312

315313
public onBackPressed(): boolean {
@@ -503,13 +501,26 @@ export class Frame extends FrameBase {
503501
}
504502
}
505503

504+
function cloneExpandedAnimator(expandedAnimator: any) {
505+
if (!expandedAnimator) {
506+
return null;
507+
}
508+
509+
const clone = expandedAnimator.clone();
510+
clone.entry = expandedAnimator.entry;
511+
clone.transitionType = expandedAnimator.transitionType;
512+
513+
return clone;
514+
}
515+
506516
function getAnimatorState(entry: BackstackEntry): AnimatorState {
507517
const expandedEntry = <any>entry;
508518
const animatorState = <AnimatorState>{};
509-
animatorState.enterAnimator = expandedEntry.enterAnimator;
510-
animatorState.exitAnimator = expandedEntry.exitAnimator;
511-
animatorState.popEnterAnimator = expandedEntry.popEnterAnimator;
512-
animatorState.popExitAnimator = expandedEntry.popExitAnimator;
519+
520+
animatorState.enterAnimator = cloneExpandedAnimator(expandedEntry.enterAnimator);
521+
animatorState.exitAnimator = cloneExpandedAnimator(expandedEntry.exitAnimator);
522+
animatorState.popEnterAnimator = cloneExpandedAnimator(expandedEntry.popEnterAnimator);
523+
animatorState.popExitAnimator = cloneExpandedAnimator(expandedEntry.popExitAnimator);
513524
animatorState.transitionName = expandedEntry.transitionName;
514525

515526
return animatorState;

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy