From e3df5b8e3bd5899378115abd220e0c97b843fbe2 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Mon, 14 Oct 2019 16:35:00 -0400 Subject: [PATCH] [+] Create history state listener --- src/components/app/app.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/components/app/app.ts b/src/components/app/app.ts index 0f988c5..3daa71d 100644 --- a/src/components/app/app.ts +++ b/src/components/app/app.ts @@ -101,6 +101,17 @@ export default class App extends Vue // Set history state (TODO: Dynamically detect initial url window.history.replaceState({lastTab: 'overall'}, '', '/overall'); + + // Create history state listener + window.onpopstate = e => + { + if (e.state) + { + // Restore previous tab + console.log(`onPopState: Current: ${this.selectedTab}, Previous: ${e.state.lastTab}`); + this.selectedTab = e.state.lastTab; + } + }; } /**