dézoom map mobile

This commit is contained in:
Valentin
2024-10-19 04:08:11 +02:00
parent 376e0af7a3
commit ec73eabda9
5 changed files with 13 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
import { defineStore } from 'pinia';
import { defineStore, mapStores } from 'pinia';
export const useLayoutStore = defineStore('layout', {
state: () => ({

View File

@@ -4,7 +4,8 @@ import { useLayoutStore } from './layout';
export const useMapStore = defineStore('mapState', {
state: () => ({
map: Object,
defaultZoom: Number,
defaultZoomDesktop: Number,
defaultZoomMobile: Number,
defaultMapCenter: Object,
currentPlace: Object,
maxZoom: Number,
@@ -18,8 +19,8 @@ export const useMapStore = defineStore('mapState', {
this.currentZoom = this.maxZoom;
},
resetMap() {
this.map.flyTo(this.defaultMapCenter, this.defaultZoom, { duration: this.duration });
this.currentZoom = this.defaultZoom;
this.map.flyTo(this.defaultMapCenter, useLayoutStore().isDesktop ? this.defaultZoomDesktop : this.defaultZoomMobile, { duration: this.duration });
this.currentZoom = useLayoutStore().isDesktop ? this.defaultZoomDesktop : this.defaultZoomMobile;
},
lockMap() {
setTimeout(() => {
@@ -35,7 +36,7 @@ export const useMapStore = defineStore('mapState', {
// map.tap.disable();
},
unlockMap() {
this.map.options.minZoom = this.defaultZoom;
this.map.options.minZoom = useLayoutStore().isDesktop ? this.defaultZoomDesktop : this.defaultZoomMobile;
this.map.options.maxZoom = this.maxZoom;
this.map.dragging.enable();
this.map.touchZoom.enable();