fix: RootLayout default open options

This commit is contained in:
Nathan Walker
2021-03-25 21:02:11 -07:00
parent 14360881e6
commit eeb68e9ce2

View File

@ -48,11 +48,10 @@ export class RootLayoutBase extends GridLayout {
view.opacity = 0; // always begin with view invisible when adding dynamically view.opacity = 0; // always begin with view invisible when adding dynamically
this.insertChild(view, this.getChildrenCount() + 1); this.insertChild(view, this.getChildrenCount() + 1);
if (options?.animation?.enterFrom) {
setTimeout(() => { setTimeout(() => {
// only apply initial state and animate after the first tick - ensures safe areas and other measurements apply correctly // only apply initial state and animate after the first tick - ensures safe areas and other measurements apply correctly
this.applyInitialState(view, options.animation.enterFrom); this.applyInitialState(view, options.animation ? options.animation.enterFrom : null);
this.getEnterAnimation(view, options.animation.enterFrom) this.getEnterAnimation(view, options.animation ? options.animation.enterFrom : null)
.play() .play()
.then(() => { .then(() => {
this.applyDefaultState(view); this.applyDefaultState(view);
@ -64,9 +63,6 @@ export class RootLayoutBase extends GridLayout {
} }
}); });
}); });
} else {
resolve();
}
} }
} catch (ex) { } catch (ex) {
if (Trace.isEnabled()) { if (Trace.isEnabled()) {
@ -253,7 +249,7 @@ export class RootLayoutBase extends GridLayout {
private applyInitialState(targetView: View, enterFrom: TransitionAnimation): void { private applyInitialState(targetView: View, enterFrom: TransitionAnimation): void {
const animationOptions = { const animationOptions = {
...defaultTransitionAnimation, ...defaultTransitionAnimation,
...enterFrom, ...(enterFrom || {}),
}; };
targetView.translateX = animationOptions.translateX; targetView.translateX = animationOptions.translateX;
targetView.translateY = animationOptions.translateY; targetView.translateY = animationOptions.translateY;
@ -275,7 +271,7 @@ export class RootLayoutBase extends GridLayout {
private getEnterAnimation(targetView: View, enterFrom: TransitionAnimation): Animation { private getEnterAnimation(targetView: View, enterFrom: TransitionAnimation): Animation {
const animationOptions = { const animationOptions = {
...defaultTransitionAnimation, ...defaultTransitionAnimation,
...enterFrom, ...(enterFrom || {}),
}; };
return new Animation([ return new Animation([
{ {