Open hyperknot opened 6 years ago
This seems like expected behavior to me. The documentation for preventDefault
says:
Prevents subsequent default processing of the event by the map. Calling this method will prevent the following default map behaviors:
- On touchstart events, the behavior of DragPanHandler
- On touchstart events, the behavior of TouchZoomRotateHandler
So if TouchZoomRotateHandler is disabled, there's nothing for preventDefault
to do on pinch gestures.
Can you say more about what you're trying to accomplish?
I'm trying to implement dragging of a feature like in the official drag point example. My problem is that if the user accidentally does a pinch instead of a drag the viewport will zoom with no way to go back.
My best idea so far is to check for originalEvent.scale!=1 and do an originalEvent.preventDefault, but even this can sometimes zoom the UI.
I'll create an example showing this behavior.
On 2018. May 16., Wed at 17:22, John Firebaugh notifications@github.com wrote:
This seems like expected behavior to me. The documentation for preventDefault says:
Prevents subsequent default processing of the event by the map. Calling this method will prevent the following default map behaviors:
- On touchstart events, the behavior of DragPanHandler
- On touchstart events, the behavior of TouchZoomRotateHandler
So if TouchZoomRotateHandler is disabled, there's nothing for preventDefault to do on pinch gestures.
Can you say more about what you're trying to accomplish?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/mapbox/mapbox-gl-js/issues/6679#issuecomment-389558901, or mute the thread https://github.com/notifications/unsubscribe-auth/AAeKj0vY0bacFyV9rpIDbng8b_zueFlKks5tzEQpgaJpZM4UBUO3 .
Do you want TouchZoomRotateHandler disabled all the time, or is disabling that just something you tried to suppress the viewport scaling?
Yes, the example I've given was just something I created for debugging. I'd like to disable touch zooming only while I'm grabbing a point.
Here are the real issues I've run into while setting up events like in "drag-a-point" example:
The dragging is actually not following the touch point. You move it up and it goes 70% up. https://zw1n04ow14.codesandbox.io/ https://codesandbox.io/s/zw1n04ow14
The touch zoom can "escape" the container sometimes. It happens both with touch zoom enabled when dragging a point, or with touch zoom disabled and manually doing preventDefault. I'm trying to create a reproducible case for this one.
OK, I managed to reproduce the "container escape" bug for touch to zoom. Just try to touch zoom the map in many different directions on an iOS device. https://jsbin.com/keguga/10
Once the zoom "escaped" the UI is destroyed as there is no way to get back to the original viewport. Silly iOS Safari remembers the viewport even after a page reload. (If you go into the URL bar and press return it'll reset the viewport, but users will probably just press the reload button).
To trigger the buggy state, try touch zooming around the bottom UI elements, like the i button or the Mapbox logo.
mapbox-gl-js version: 0.45.0 browser: iOS 11.3
Steps to Trigger Behavior
passive: false
event, liketouchmove
which callse.preventDefault()
Link to Demonstration
full screen: https://03qo50z3rw.codesandbox.io/ https://codesandbox.io/s/03qo50z3rw
Expected Behavior
e.preventDefault()
should disable browser viewport zoomingActual Behavior
The browser window zooms, even with
e.preventDefault()
I tried an alternative,
e.originalEvent.preventDefault()
which seems to work, however the official drag point example usese.preventDefault()
.cc: @jfirebaugh ref: https://github.com/mapbox/mapbox-gl-js/issues/6095 pr: https://github.com/mapbox/mapbox-gl-js/pull/6248