aboutsummaryrefslogtreecommitdiff
path: root/modern/src
diff options
context:
space:
mode:
authorMustafa Taha Şahin <taha.sahin@metu.edu.tr>2021-04-02 02:40:07 +0300
committerMustafa Taha Şahin <taha.sahin@metu.edu.tr>2021-04-02 02:40:07 +0300
commit56567e683734c1f990fb59f193c2d96df706b6b0 (patch)
tree9ef8e8ca7d7a9d6473e16f0696f3a390007ad905 /modern/src
parent203df66558a9d92dce11d6121e576886d29c2e77 (diff)
downloadtrackermap-web-56567e683734c1f990fb59f193c2d96df706b6b0.tar.gz
trackermap-web-56567e683734c1f990fb59f193c2d96df706b6b0.tar.bz2
trackermap-web-56567e683734c1f990fb59f193c2d96df706b6b0.zip
another refactoring
Diffstat (limited to 'modern/src')
-rw-r--r--modern/src/map/Map.js23
1 files changed, 11 insertions, 12 deletions
diff --git a/modern/src/map/Map.js b/modern/src/map/Map.js
index 7f789734..d83c297d 100644
--- a/modern/src/map/Map.js
+++ b/modern/src/map/Map.js
@@ -35,13 +35,6 @@ const updateReadyValue = value => {
readyListeners.forEach(listener => listener(value));
};
-const onIdle = function () {
- const zoom = Math.round(map.getZoom())
- if (zoom !== map.getZoom()) {
- map.zoomTo(zoom)
- }
-};
-
const initMap = async () => {
const background = await loadImage('images/background.svg');
await Promise.all(deviceCategories.map(async category => {
@@ -102,12 +95,18 @@ const Map = ({ children }) => {
useEffect(() => {
if (mapReady && Object.values(map.getStyle().sources).some(e => e.type === 'raster')) {
- map.scrollZoom.setWheelZoomRate(1);
- map.on('idle', onIdle);
+ const onIdle = function () {
+ const zoom = Math.round(map.getZoom());
+ if (zoom !== map.getZoom()) {
+ map.zoomTo(zoom);
+ }
+ };
+ map.scrollZoom.setWheelZoomRate(1);
+ map.on('idle', onIdle);
+ return () => {
+ map.scrollZoom.setWheelZoomRate(1/450);
+ map.off('idle', onIdle);
}
- return () => {
- map.scrollZoom.setWheelZoomRate(1/450);
- map.off('idle', onIdle);
}
}, [mapReady]);