Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #599 from deckgo/resize-deck-on-navigation
Browse files Browse the repository at this point in the history
fix: resize landing deck on navigation
  • Loading branch information
peterpeterparker authored Jan 20, 2020
2 parents 87a7693 + 3e5c841 commit b660604
Showing 1 changed file with 27 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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<void> {
return new Promise<void>(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');

Expand Down

0 comments on commit b660604

Please sign in to comment.