update(zoom): clamp transform values

Signed-off-by: Braks <78412429+bcakmakoglu@users.noreply.github.com>
This commit is contained in:
Braks
2021-11-18 14:14:05 +01:00
parent 14980e38b7
commit 60327c4ca0
+10 -1
View File
@@ -190,7 +190,16 @@ watch(
},
{ flush: 'pre' },
)
watch(transform, (val) => (store.transform = [val.x, val.y, val.zoom]), { flush: 'pre' })
watch(
transform,
(val) =>
(store.transform = [
clamp(val.x, store.translateExtent[0][0], store.translateExtent[1][0]),
clamp(val.y, store.translateExtent[0][0], store.translateExtent[1][0]),
clamp(val.zoom, store.translateExtent[0][0], store.translateExtent[1][0]),
]),
{ flush: 'pre' },
)
const { zoomIn, zoomOut, zoomTo, transform: setTransform, fitView } = useZoomPanHelper()
watchOnce(