mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 21:38:13 +00:00
feat: saving train table scroll position
This commit is contained in:
@@ -1,5 +1,12 @@
|
|||||||
<template>
|
<template>
|
||||||
<transition name="status-anim" mode="out-in" tag="div" class="train-table">
|
<transition
|
||||||
|
name="status-anim"
|
||||||
|
mode="out-in"
|
||||||
|
tag="div"
|
||||||
|
class="train-table"
|
||||||
|
@scroll="onScroll"
|
||||||
|
ref="trainTableRef"
|
||||||
|
>
|
||||||
<div :key="apiStore.dataStatuses.connection">
|
<div :key="apiStore.dataStatuses.connection">
|
||||||
<div class="table-warning" key="offline" v-if="store.isOffline">
|
<div class="table-warning" key="offline" v-if="store.isOffline">
|
||||||
{{ $t('app.offline') }}
|
{{ $t('app.offline') }}
|
||||||
@@ -39,6 +46,10 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
data: () => ({
|
||||||
|
scrollTop: 0
|
||||||
|
}),
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
const store = useMainStore();
|
const store = useMainStore();
|
||||||
const apiStore = useApiStore();
|
const apiStore = useApiStore();
|
||||||
@@ -58,6 +69,16 @@ export default defineComponent({
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
activated() {
|
||||||
|
(this.$refs['trainTableRef'] as HTMLElement).scrollTop = this.scrollTop;
|
||||||
|
},
|
||||||
|
|
||||||
|
methods: {
|
||||||
|
onScroll(e: Event) {
|
||||||
|
this.scrollTop = (e.target as HTMLElement).scrollTop;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
computed: {
|
computed: {
|
||||||
dataStatus() {
|
dataStatus() {
|
||||||
if (this.store.isOffline) return Status.Data.Offline;
|
if (this.store.isOffline) return Status.Data.Offline;
|
||||||
@@ -92,6 +113,4 @@ export default defineComponent({
|
|||||||
|
|
||||||
background: #1a1a1a;
|
background: #1a1a1a;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user