-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Refactor interaction handlers to never unbind their event listeners #2891
Comments
I suppose this happens because |
When I run this example:
Looking at the code, this is what I'd expect to happen. You are binding two interaction handlers to the double click event and the more recently bound one takes precedence. If you would like subsequent double clicks to zoom to the bounds, don't enable the |
@lucaswoj - I know this is old, but I missed your comment above. I see how you are reading the code and if you assume that |
@lucaswoj and I talked this over a bit today. I was thinking that the user-provided callback was being overwritten with the doubleClickZoom callback. This is not true. The problem here stems from the order of operations. As both doubleClickZoom and the user-provided callback change the camera the second event to run overrides the first. This can be solved by users by Always disabling doubleClickZoom when they are creating |
@mcwhittemore see my comment above. |
@mcwhittemore Yeah, but order of events is exactly what I meant. After |
@mourner - gotcha. I think it's wiser to have the default interaction handlers run last rather than first. This way the user can make a dynamic interaction such as if the user clicked on a shape zoom to the bounds of that shape, else zoom in. This would require being able to disable the handler once (via stop propagation?). Right now we do this in Draw by disabling the handler and then enabling it via a setTimeout. |
Another solution that may work well for the GL Draw use case is adding a Per discussion in #3290, we may need to resolve #3290 along side resolving this issue. |
I'm a fan of the |
mapbox-gl-js version: 0.21.0
Steps to Trigger Behavior
https://jsbin.com/havivaruwe/edit?html,output
Expected Behavior
I expect the fit bounds call to bring me to the bounds
Actual Behavior
the double click zoom happens.
The text was updated successfully, but these errors were encountered: