From d37657d3e28e93dc015ca7ebfa7f2783092e4273 Mon Sep 17 00:00:00 2001 From: James Lyne Date: Tue, 27 Jul 2021 02:28:01 +0100 Subject: [PATCH] Prevent unnecessary marker repositioning on world change --- src/components/map/vector/Areas.vue | 5 ++--- src/components/map/vector/Circles.vue | 5 ++--- src/components/map/vector/Lines.vue | 5 ++--- src/components/map/vector/Markers.vue | 5 ++--- 4 files changed, 8 insertions(+), 12 deletions(-) diff --git a/src/components/map/vector/Areas.vue b/src/components/map/vector/Areas.vue index 4b40b9f..c7bead8 100644 --- a/src/components/map/vector/Areas.vue +++ b/src/components/map/vector/Areas.vue @@ -101,9 +101,8 @@ export default defineComponent({ } }; - //FIXME: Prevent unnecessary repositioning when changing worlds - watch(currentMap, (newValue) => { - if(newValue) { + watch(currentMap, (newValue, oldValue) => { + if(newValue && (!oldValue || oldValue.world === newValue.world)) { const converter = getPointConverter(); for (const [id, area] of props.set.areas) { diff --git a/src/components/map/vector/Circles.vue b/src/components/map/vector/Circles.vue index 71e7636..a9ce9e2 100644 --- a/src/components/map/vector/Circles.vue +++ b/src/components/map/vector/Circles.vue @@ -101,9 +101,8 @@ export default defineComponent({ } }; - //FIXME: Prevent unnecessary repositioning when changing worlds - watch(currentMap, (newValue) => { - if(newValue) { + watch(currentMap, (newValue, oldValue) => { + if(newValue && (!oldValue || oldValue.world === newValue.world)) { const converter = getPointConverter(); for (const [id, circle] of props.set.circles) { diff --git a/src/components/map/vector/Lines.vue b/src/components/map/vector/Lines.vue index bbcc243..6035f22 100644 --- a/src/components/map/vector/Lines.vue +++ b/src/components/map/vector/Lines.vue @@ -100,9 +100,8 @@ export default defineComponent({ } }; - //FIXME: Prevent unnecessary repositioning when changing worlds - watch(currentMap, (newValue) => { - if(newValue) { + watch(currentMap, (newValue, oldValue) => { + if(newValue && (!oldValue || oldValue.world === newValue.world)) { const converter = getPointConverter(); for (const [id, line] of props.set.lines) { diff --git a/src/components/map/vector/Markers.vue b/src/components/map/vector/Markers.vue index 3aba2a6..abff197 100644 --- a/src/components/map/vector/Markers.vue +++ b/src/components/map/vector/Markers.vue @@ -100,9 +100,8 @@ export default defineComponent({ } }; - //FIXME: Prevent unnecessary repositioning when changing worlds - watch(currentMap, (newValue) => { - if(newValue) { + watch(currentMap, (newValue, oldValue) => { + if(newValue && (!oldValue || oldValue.world === newValue.world)) { for (const [id, marker] of props.set.markers) { updateMarker(layers.get(id), marker, getPointConverter()); }