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

Interactions stay disabled after touching an ignored element #46

Open
gaellafond opened this issue Jan 2, 2020 · 1 comment
Open

Interactions stay disabled after touching an ignored element #46

gaellafond opened this issue Jan 2, 2020 · 1 comment

Comments

@gaellafond
Copy link

Issue:
Interactions are not working after scroll page + touch the map, on mobile.

How to reproduce:

  1. Scroll the page by touching the map with one finger. The "Use 2 fingers to move the map" appear.
  2. Touch the map before the message disappear.
  3. The interactions are disabled and are never re-enabled. This causes issues such as clickable map elements such as polygons are no longer clickable, the zoom out button zoom the map in when double click, etc.

NOTE: The bug is also reproducible with Google Chrome desktop, when mobile device is turned on in the developer tools.

Solution:
Add the following line:

this._enableInteractions();

in method _handleTouch

        _handleTouch: function (e) {
            //Disregard touch events on the minimap if present
            var ignoreList = ["leaflet-control-minimap", "leaflet-interactive", "leaflet-popup-content", "leaflet-popup-content-wrapper", "leaflet-popup-close-button", "leaflet-control-zoom-in", "leaflet-control-zoom-out"];

            var ignoreElement = false;
            for (var i = 0; i < ignoreList.length; i++) {
                if (L.DomUtil.hasClass(e.target, ignoreList[i])) {
                    ignoreElement = true;
                }
            }

            if (ignoreElement) {
                if (L.DomUtil.hasClass(e.target, "leaflet-interactive") && e.type === "touchmove" && e.touches.length === 1) {
                    L.DomUtil.addClass(this._map._container, "leaflet-gesture-handling-touch-warning");
                    this._disableInteractions();
                } else {

                    // ###### HERE ######
                    this._enableInteractions();

                    L.DomUtil.removeClass(this._map._container, "leaflet-gesture-handling-touch-warning");
                }
                return;
            }
            ...
@gaellafond gaellafond changed the title Interactions stay disabled after touch an ignored element Interactions stay disabled after touching an ignored element Jan 2, 2020
@jcgiuffrida
Copy link

I had a similar problem: on desktop when users mouse over a Polygon and then mouse back over the underlying tile layer, they can't click + hold to drag the map. This solution fixed that too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants