Skip to content

Commit

Permalink
fix shaky sprites on scrollZoom (mapbox#7558)
Browse files Browse the repository at this point in the history
  • Loading branch information
mollymerp authored and pirxpilot committed Jun 15, 2019
1 parent 9904cd2 commit 25c4cca
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/ui/handler/scroll_zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function scrollZoomHandler(_map) {

let enabled = false;
let active = false;
let zooming = false;
let aroundCenter;

let _lastWheelEvent;
Expand Down Expand Up @@ -100,6 +101,10 @@ function scrollZoomHandler(_map) {
return active;
}

function isZooming() {
return zooming;
}

/**
* Enables the "scroll to zoom" interaction.
*
Expand Down Expand Up @@ -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 }));
Expand Down Expand Up @@ -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}));
Expand All @@ -276,6 +283,7 @@ function scrollZoomHandler(_map) {

return {
isActive,
isZooming,
isEnabled,
enable,
disable,
Expand Down
2 changes: 1 addition & 1 deletion src/ui/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ class Map extends Camera {
isZooming() {
return this._zooming ||
this.touchZoomRotate.isActive() ||
this.scrollZoom.isActive();
this.scrollZoom.isZooming();
}

/**
Expand Down

0 comments on commit 25c4cca

Please sign in to comment.