From 3e5c841e30b23c7ae31e87d786a793ccb2c73011 Mon Sep 17 00:00:00 2001 From: peterpeterparker Date: Mon, 20 Jan 2020 11:23:54 +0100 Subject: [PATCH] fix: resize landing deck on navigation Signed-off-by: peterpeterparker --- .../app-landing-deck/app-landing-deck.tsx | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/studio/src/app/components/landing/app-landing-deck/app-landing-deck.tsx b/studio/src/app/components/landing/app-landing-deck/app-landing-deck.tsx index ec687b974..71491dcc7 100644 --- a/studio/src/app/components/landing/app-landing-deck/app-landing-deck.tsx +++ b/studio/src/app/components/landing/app-landing-deck/app-landing-deck.tsx @@ -1,4 +1,4 @@ -import {Component, Element, h, State} from '@stencil/core'; +import {Component, Element, h, Listen, State} from '@stencil/core'; import {isMobile} from '@deckdeckgo/utils'; @@ -20,6 +20,32 @@ export class AppLandingDeck { @State() private deckTransition: 'slide' | 'fade' = isMobile() ? 'fade' : 'slide'; + @Listen('ionRouteDidChange', {target: 'window'}) + async onRouteDidChange($event: CustomEvent) { + if (!$event || !$event.detail) { + return; + } + + if ($event.detail.to && $event.detail.to === '/' && $event.detail.from && $event.detail.to !== $event.detail.from) { + await this.updateDeckSize(); + } + } + + private updateDeckSize(): Promise { + return new Promise(async (resolve) => { + const deck: HTMLElement = this.el.querySelector('deckgo-deck'); + + if (!deck) { + resolve(); + return; + } + + await (deck as any).initSlideSize(); + + resolve(); + }); + } + private async updateDeckPosition() { const deck: HTMLElement = this.el.querySelector('deckgo-deck');