diff --git a/src/ui/handler/scroll_zoom.js b/src/ui/handler/scroll_zoom.js index 8dd00dd37c3..16f2b21e7d1 100644 --- a/src/ui/handler/scroll_zoom.js +++ b/src/ui/handler/scroll_zoom.js @@ -66,6 +66,7 @@ function scrollZoomHandler(_map) { let enabled = false; let active = false; + let zooming = false; let aroundCenter; let _lastWheelEvent; @@ -100,6 +101,10 @@ function scrollZoomHandler(_map) { return active; } + function isZooming() { + return zooming; + } + /** * Enables the "scroll to zoom" interaction. * @@ -195,6 +200,7 @@ function scrollZoomHandler(_map) { frame.cancel(); active = true; + zooming = true; _map.fire(new Event('movestart', { originalEvent: _lastWheelEvent })); _map.fire(new Event('zoomstart', { originalEvent: _lastWheelEvent })); @@ -266,6 +272,7 @@ function scrollZoomHandler(_map) { if (finished) { active = false; _finishTimeout = setTimeout(() => { + zooming = false; _finishTimeout = undefined; _map.fire(new Event('zoomend', {originalEvent: _lastWheelEvent})); _map.fire(new Event('moveend', {originalEvent: _lastWheelEvent})); @@ -276,6 +283,7 @@ function scrollZoomHandler(_map) { return { isActive, + isZooming, isEnabled, enable, disable, diff --git a/src/ui/map.js b/src/ui/map.js index ec4263bce40..1073e8ac902 100644 --- a/src/ui/map.js +++ b/src/ui/map.js @@ -506,7 +506,7 @@ class Map extends Camera { isZooming() { return this._zooming || this.touchZoomRotate.isActive() || - this.scrollZoom.isActive(); + this.scrollZoom.isZooming(); } /**