Skip to content

Commit

Permalink
add smooth zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
jedi-of-the-sea committed Aug 1, 2024
1 parent 4a5733f commit 53054f0
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/plugins/Zoom/src/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export const makeStoreModule = () => {
getters: { maximumZoomLevel, minimumZoomLevel, zoomLevel },
rootGetters: { map },
commit,
dispatch,
},
payload
) {
Expand All @@ -41,7 +42,7 @@ export const makeStoreModule = () => {
map
) {
commit('setZoomLevel', payload)
map.getView().setZoom(payload)
dispatch('smoothZoom')
}
},
increaseZoomLevel({ dispatch, getters: { zoomLevel } }): void {
Expand All @@ -50,6 +51,15 @@ export const makeStoreModule = () => {
decreaseZoomLevel({ dispatch, getters: { zoomLevel } }): void {
dispatch('setZoomLevel', zoomLevel - 1)
},
smoothZoom({ rootGetters: { map }, getters: { zoomLevel } }): void {
const view = map.getView()
if (view) {
view.animate({
zoom: zoomLevel,
duration: 1000,
})
}
},
},
mutations: {
...generateSimpleMutations(getInitialState()),
Expand Down

0 comments on commit 53054f0

Please sign in to comment.