aboutsummaryrefslogtreecommitdiff
path: root/viewer/src/views
diff options
context:
space:
mode:
authorZero~Informatique2020-02-11 03:30:08 +0100
committerNotkea2020-02-11 18:35:16 +0100
commite61a7c84f1a1753186980ff1990ee146395ddfc1 (patch)
tree9b4af7e5a92f358dc24c51c2ef5dc570c13521ed /viewer/src/views
parentbaa22ba2fb8d53b08487ef261ebde6028675448e (diff)
downloadldgallery-e61a7c84f1a1753186980ff1990ee146395ddfc1.tar.gz
viewer: store and restore the scroll position through navigation
GitHub: closes #58
Diffstat (limited to 'viewer/src/views')
-rw-r--r--viewer/src/views/MainLayout.vue15
1 files changed, 13 insertions, 2 deletions
diff --git a/viewer/src/views/MainLayout.vue b/viewer/src/views/MainLayout.vue
index 31b0440..12388a9 100644
--- a/viewer/src/views/MainLayout.vue
+++ b/viewer/src/views/MainLayout.vue
@@ -21,7 +21,7 @@
21 <div :class="{'fullscreen': $uiStore.fullscreen, 'fullwidth': $uiStore.fullWidth}"> 21 <div :class="{'fullscreen': $uiStore.fullscreen, 'fullwidth': $uiStore.fullWidth}">
22 <panel-top v-if="!isLoading" class="layout layout-top" /> 22 <panel-top v-if="!isLoading" class="layout layout-top" />
23 <panel-left v-if="!isLoading" class="layout layout-left" /> 23 <panel-left v-if="!isLoading" class="layout layout-left" />
24 <router-view v-if="!isLoading" class="layout layout-content scrollbar" /> 24 <router-view v-if="!isLoading" ref="content" class="layout layout-content scrollbar" />
25 <b-loading :active="isLoading" is-full-page /> 25 <b-loading :active="isLoading" is-full-page />
26 <ld-key-press :keycode="27" @action="$uiStore.fullscreen=false" /> 26 <ld-key-press :keycode="27" @action="$uiStore.fullscreen=false" />
27 27
@@ -32,20 +32,31 @@
32</template> 32</template>
33 33
34<script lang="ts"> 34<script lang="ts">
35import { Component, Vue } from "vue-property-decorator"; 35import { Component, Vue, Ref, Watch } from "vue-property-decorator";
36import PanelLeft from "./PanelLeft.vue"; 36import PanelLeft from "./PanelLeft.vue";
37import PanelTop from "./PanelTop.vue"; 37import PanelTop from "./PanelTop.vue";
38import { Route } from "vue-router";
38 39
39@Component({ 40@Component({
40 components: { PanelLeft, PanelTop }, 41 components: { PanelLeft, PanelTop },
41}) 42})
42export default class MainLayout extends Vue { 43export default class MainLayout extends Vue {
44 @Ref() readonly content!: Vue;
45
43 isLoading: boolean = true; 46 isLoading: boolean = true;
47 scrollPositions: ScrollPosition = {};
44 48
45 mounted() { 49 mounted() {
46 this.fetchGalleryItems(); 50 this.fetchGalleryItems();
47 } 51 }
48 52
53 @Watch("$route")
54 routeChanged(newRoute: Route, oldRoute: Route) {
55 const el = this.content.$el;
56 this.scrollPositions[oldRoute.path] = el.scrollTop;
57 this.$nextTick(() => (el.scrollTop = this.scrollPositions[newRoute.path]));
58 }
59
49 fetchGalleryItems() { 60 fetchGalleryItems() {
50 this.isLoading = true; 61 this.isLoading = true;
51 this.$galleryStore 62 this.$galleryStore