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

Fixed #2784 #5274

Merged
merged 3 commits into from
Oct 2, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion src/ui/bind_handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,10 @@ module.exports = function bindHandlers(map: Map, options: {}) {
}

function onMouseDown(e: MouseEvent) {
map.stop();
if (!map._isUserDoubleClick) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of adding this property to the map object, you could create a DoubleClickZoomHandler#isActive method as we do in with some of the other handles (ex. https://github.com/mapbox/mapbox-gl-js/blob/master/src/ui/handler/box_zoom.js#L52), so you could call map.doubleClickZoom.isActive() for this conditional

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I'll switch to using isActive. As for the test, there aren't any existing tests for the DoubleClickZoomHandler, and I'm kind of a little too busy to figure out how to write one to catch this specific bug. Better someone who knows the test framework well should do it.

map.stop();
}

startPos = DOM.mousePos(el, e);
fireMouseEvent('mousedown', e);

Expand Down
8 changes: 8 additions & 0 deletions src/ui/handler/dblclick_zoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ class DoubleClickZoomHandler {

util.bindAll([
'_onDblClick',
'_onZoomEnd'
], this);
}

Expand Down Expand Up @@ -56,12 +57,19 @@ class DoubleClickZoomHandler {
}

_onDblClick(e: any) {
this._map._isUserDoubleClick = true;
this._map.on('zoomend', this._onZoomEnd);
this._map.zoomTo(
this._map.getZoom() + (e.originalEvent.shiftKey ? -1 : 1),
{around: e.lngLat},
e
);
}

_onZoomEnd() {
this._map._isUserDoubleClick = false;
this._map.off('zoomend', this._onZoomEnd);
}
}

module.exports = DoubleClickZoomHandler;
1 change: 1 addition & 0 deletions src/ui/map.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ class Map extends Camera {
_refreshExpiredTiles: boolean;
_hash: Hash;
_delegatedListeners: any;
_isUserDoubleClick: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this flag anymore

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


scrollZoom: ScrollZoomHandler;
boxZoom: BoxZoomHandler;
Expand Down