mirror of
https://github.com/Spythere/pojazdownik.git
synced 2026-05-03 05:18:10 +00:00
chore(wiki): preserving scroll state
This commit is contained in:
@@ -50,7 +50,7 @@
|
|||||||
:data-preview="vehicle.type === store.chosenVehicle?.type"
|
:data-preview="vehicle.type === store.chosenVehicle?.type"
|
||||||
@click="previewVehicle(vehicle)"
|
@click="previewVehicle(vehicle)"
|
||||||
@dblclick="addVehicle(vehicle)"
|
@dblclick="addVehicle(vehicle)"
|
||||||
@keydown.enter="previewVehicle(vehicle)"
|
@keydown.enter="onVehicleSelect(vehicle)"
|
||||||
tabindex="0"
|
tabindex="0"
|
||||||
>
|
>
|
||||||
<img loading="lazy" width="120" :src="getThumbnailURL(vehicle.type, 'small')" />
|
<img loading="lazy" width="120" :src="getThumbnailURL(vehicle.type, 'small')" />
|
||||||
@@ -117,9 +117,19 @@ export default defineComponent({
|
|||||||
sorterDirection: 'asc' as SorterDirection,
|
sorterDirection: 'asc' as SorterDirection,
|
||||||
|
|
||||||
filterType: 'vehicles-all' as FilterType,
|
filterType: 'vehicles-all' as FilterType,
|
||||||
|
|
||||||
|
lastScrollTop: 0,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
|
deactivated() {
|
||||||
|
this.lastScrollTop = (this.$refs['vehicles'] as HTMLUListElement)?.scrollTop || 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
activated() {
|
||||||
|
(this.$refs['vehicles'] as HTMLUListElement)?.scrollTo({ top: this.lastScrollTop });
|
||||||
|
},
|
||||||
|
|
||||||
watch: {
|
watch: {
|
||||||
computedVehicles() {
|
computedVehicles() {
|
||||||
const vehiclesRef = this.$refs['vehicles'] as HTMLElement;
|
const vehiclesRef = this.$refs['vehicles'] as HTMLElement;
|
||||||
@@ -133,7 +143,8 @@ export default defineComponent({
|
|||||||
methods: {
|
methods: {
|
||||||
isTractionUnit,
|
isTractionUnit,
|
||||||
|
|
||||||
onItemSelect(vehicle: IVehicle) {
|
onVehicleSelect(vehicle: IVehicle) {
|
||||||
|
if (this.store.chosenVehicle?.type === vehicle.type) this.addVehicle(vehicle);
|
||||||
this.previewVehicle(vehicle);
|
this.previewVehicle(vehicle);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user