-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Fixed #2784 #5274
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @aparajita thank you very much for your contribution!
I have verified that this fix works on my mobile device. In addition to my comment, do you have time to add a test that would catch this bug?
src/ui/bind_handlers.js
Outdated
@@ -46,7 +46,10 @@ module.exports = function bindHandlers(map: Map, options: {}) { | |||
} | |||
|
|||
function onMouseDown(e: MouseEvent) { | |||
map.stop(); | |||
if (!map._isUserDoubleClick) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
Thanks for the update @aparajita. I started writing a test but it turns out that the @jfirebaugh do you have other ideas for testing this? |
src/ui/map.js
Outdated
@@ -244,6 +244,7 @@ class Map extends Camera { | |||
_refreshExpiredTiles: boolean; | |||
_hash: Hash; | |||
_delegatedListeners: any; | |||
_isUserDoubleClick: boolean; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
@aparajita once you remove the unneeded flag on the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you @aparajita !
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you @aparajita !
Previously, a zoom initiated by a double tap on a touchscreen device would stop as soon as the user lifted his/her finger from the second tap. This was due to the map's mousedown handler calling
map.stop()
.This PR sets a flag when the user initiates a double click/tap, which is then checked before calling
map.stop()
in the map's mousedown handler.mousedown events are still received and passed to any handlers during a user-initiated zoom animation, but they will not stop the zoom.