question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ios: dragging=false but scrolling on map not possible

See original GitHub issue

How to reproduce

  • Leaflet version I’m using: 1.0.3
  • Browser (with version) I’m using: Safari/602.1
  • OS/Platform (with version) I’m using: iOS 10

What behaviour I’m expecting and which behaviour I’m seeing

When dragging is disabled, i expect the page to scroll when i drag over the map on ios. instead, nothing happens. on android i can scroll by dragging if dragging=false.

Minimal example reproducing the issue

On ios, it’s not possible to scroll the page when dragging on the map:

https://jsfiddle.net/geg8yLe3/

This is similar to #5343

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:20 (5 by maintainers)

github_iconTop GitHub Comments

23reactions
SimonEastcommented, Nov 6, 2017

I can confirm that the following code seems to be a valid workaround for ensuring that a single finger scrolls the page and not the map, while still allowing for two-finger zoom+pan of the map, as well as tapping on markers. This improves usability on mobile when a map is a part of a larger page that requires scrolling.

L.map('map', {
    dragging: !L.Browser.mobile,
    tap: !L.Browser.mobile
})

Confirmed in iOS 10 Safari and Chrome. Not yet fully tested on Android.

2reactions
perliedmancommented, Jul 31, 2017

@herrernst huh, nice analysis! Thanks!

It is definitely the tap handler that causes this. Looking at the test code we used in #4051, we actually had tap: false.

So, for now, the workaround is to not only set dragging: false but also tap: false to achieve desired behavior.

I’ve submitted #5670 in an attempt to address this, so that we do not preventDefault for the source of a simulated event unless there is handler for the simulated event.

Read more comments on GitHub >

github_iconTop Results From Across the Web

DragGesture + ScrollView = problem… - Apple Developer
When placing a DragGesture on a view containing a ScrollView, dragging within the ScrollView causes onChanged to trigger, while onEnded does not trigger....
Read more >
How to prevent scroll wheel on mobile but drag the map when ...
I'm using a full width map with Google Maps Api, to prevent the scroll wheel on Desktop I've add the property: scrollwheel:false ....
Read more >
Can't continue scrolling on mobile devices when a map ...
var map = L.map('map', {dragging: false}).setView(center, 3);. But option 3 will always disable it. That might not always be desired.
Read more >
Maps JavaScript API Release Notes - Google Developers
Maps JS API no longer considers US as a default region in Geocoder if it's not ... Versions 3.49 and 3.48 are still...
Read more >
touch-action - CSS: Cascading Style Sheets - MDN Web Docs
Note: After a gesture starts, changes to touch-action will not have ... Note that scrolling "up" (pan-up) means that the user is dragging...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found