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

Do not prevent default on source of simulated event if simulated event is unhandled #5670

Closed
wants to merge 1 commit into from

Conversation

perliedman
Copy link
Member

This allows for example touchstart events to propagate so that they can be used to scroll the map when dragging is disabled. This fixes #5425.

@herrernst
Copy link

This unfortunately now has a bad side effect: In Safari on iOS, enabling dragging now results in not only scrolling the map, but also the page. But this "double-scrolling" doesn't happen anymore after you have pinch-zoomed once. See attached video (this branch with default options). I have not found out why this happens, maybe you have an idea.

leaflet-ios-safari-drag

@perliedman
Copy link
Member Author

@herrernst can you share a code example which exhibits this problem? Also, I don't have any iOS devices, so any help you could provide to examine why this happens would be of great help.

@herrernst
Copy link

herrernst commented Sep 6, 2017

Okay, that wasn't so easy, but I found the reason: Safari on iOS 10 has a weird behaviour where preventDefault on touchmove events doesn't stop scrolling when the handler is added "later" (like in Draggable, where it is added in the touchstart handler):
http://www.openradar.me/28479522
http://www.openradar.me/28359335

So one thing you could do is to preventDefault() already in the touchstart handler, like how it's done in Map.TouchZoom.
I have done so in my fork, and it seems to work, I hope it has not any unwanted side effects: herrernst@1eadeab

(By the way, if you do have a Mac, you can install Xcode and use the iOS Simulator.)

@perliedman
Copy link
Member Author

Wow, thanks, really nice find! You just have to love these little quirks in certain OS/browser combinations... 😖

I'll have to think for a bit about the potential consequences of your simple and elegant fix. Hopefully we can use it.

@SimonEast
Copy link

Did anyone get any further with @herrernst's tweak? We're currently building a map application for the World Health Organisation and we'd love to have iOS scrolling fixed.

@jonkoops jonkoops deleted the only-prevent-used-simulated-events branch May 23, 2022 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ios: dragging=false but scrolling on map not possible
4 participants