-
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
Prevent draggable marker touch event propagation #9755
Comments
Try this: map.on('touchmove', (e) => e.originalEvent.stopPropagation()); |
Hi @mourner. Thanks for the reply. That's perfect - thank you. Thanks, |
Hi @mourner! 👋 Sorry to re-open this issue. I've just got back to working on the Messenger webview and your solution above only solves half of the problem. It now avoids propagating the I thought I might be able to stop event propagation on the Some example code I tried but it doesn't work as const marker = new mapboxgl.Marker({
draggable
})
.setLngLat([longitude, latitude])
.addTo(map);
// Complains that "event.originalEvent" is undefined
marker.on('drag', (event) => event.originalEvent.stopPropagation(); I'm sure it's something obvious again but is there a way to allow dynamic markers but avoid the event propagation to the parent webview again? Thanks! |
Hi @mourner. Sorry to tag you again. Have you got any ideas about the above question? Thanks, |
Hi guys, did you manage to fix the issue above? |
mapbox-gl-js version: v1.9.0
Question
I'm using Mapbox in a Facebook Messenger chatbot which renders the map inside an HTML webview. When dragging a draggable marker, the
touchmove
event also gets propagated to the parent webview. This then moves it up and down. I can't immediately see a way to get the event in the drag handlers so that I could callevent. stopPropagation()
.Here's an example of the issue:
Is there an accepted method to achieve this?
Can I get access to the events in the drag handlers or is there a better way to do this?
Thanks!
Links to related documentation
https://docs.mapbox.com/mapbox-gl-js/api/markers/#marker-events
The text was updated successfully, but these errors were encountered: