Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

backport #7558 to release branch #7564

Merged
merged 1 commit into from
Nov 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/ui/handler/scroll_zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class ScrollZoomHandler {
_el: HTMLElement;
_enabled: boolean;
_active: boolean;
_zooming: boolean;
_aroundCenter: boolean;
_around: Point;
_aroundPoint: Point;
Expand Down Expand Up @@ -78,10 +79,19 @@ class ScrollZoomHandler {
return !!this._enabled;
}

/*
* Active state is turned on and off with every scroll wheel event and is set back to false before the map
* render is called, so _active is not a good candidate for determining if a scroll zoom animation is in
* progress.
*/
isActive() {
return !!this._active;
}


isZooming() {
return !!this._zooming;
}
/**
* Enables the "scroll to zoom" interaction.
*
Expand Down Expand Up @@ -182,6 +192,7 @@ class ScrollZoomHandler {
}

this._active = true;
this._zooming = true;
this._map.fire(new Event('movestart', {originalEvent: e}));
this._map.fire(new Event('zoomstart', {originalEvent: e}));
if (this._finishTimeout) {
Expand Down Expand Up @@ -261,6 +272,7 @@ class ScrollZoomHandler {
if (finished) {
this._active = false;
this._finishTimeout = setTimeout(() => {
this._zooming = false;
this._map.fire(new Event('zoomend', {originalEvent: this._lastWheelEvent}));
this._map.fire(new Event('moveend', {originalEvent: this._lastWheelEvent}));
delete this._targetZoom;
Expand Down
2 changes: 1 addition & 1 deletion src/ui/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,7 @@ class Map extends Camera {
*/
isZooming(): boolean {
return this._zooming ||
this.scrollZoom.isActive();
this.scrollZoom.isZooming();
}

/**
Expand Down