-
Notifications
You must be signed in to change notification settings - Fork 111
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
Dragging not working with Leaflet 1.9.2 #47
Comments
hi, i met this problem recently too.
I found that the L.Browser.touch is always true when i run my App on Chrome, the browser(or event listener) listen the touch instead of mouse events, this is why the 'MapDrag' event is not be canceled when i drag the side-by-side bar,
but this way has a drawback that it cannot work on mobile platphone or other touchable instruments. |
Downstream packages (e.g., folium, ipyleaflet) are having the same issue. @oisact Could you submit a PR to fix the issue since you already figured it out? jupyter-widgets/ipyleaflet#1066 |
uses fix described in first post of digidem/leaflet-side-by-side#47
Any updates on this issue? This bug essentially makes this plugin useless. |
It is not working with 1.9.3 either. But thanks to the fix from @oisact . |
Can confirm 1.9.4 still has the same issue. @oisact fix did the trick for now. |
Thanks @oisact! - simple and well explained fix for 1.9.4 |
I tried this and worked for me. (version 2.2.0) function getRangeEvent(range) {
return 'input';
}
/* your logic */
L.Control.CustomCompare = L.Control.Compare.extend({
_addEvents: function () {
const range = this._range;
const map = this._map;
if (!map || !range) return;
map.on("move", this._updateClip, this);
map.on("layeradd layerremove", this._updateLayers, this);
L.DomEvent.on(range, getRangeEvent(range), this._updateClip, this);
L.DomEvent.on(range, "touchstart mousedown", () => {
map.dragging.disable();
});
L.DomEvent.on(range, "touchend mouseup", () => {
map.dragging.enable();
});
}
});
new L.Control.CustomCompare([leftLayer], [rightLayer]).addTo(map); |
this is a fix to issue 47 digidem#47
With the latest Leaflet (Leaflet 1.9.2) dragging the control is not working correctly. The map itself is being dragged. There is a simple fix. Add:
L.DomEvent.disableClickPropagation(this._container);
To the addTo function (I'm calling it right before the
return this
). This disables propagation of click events through to the map.Optionally, the functions
cancelMapDrag
anduncancelMapDrag
are not serving any purpose, and they (and the event hooks to them) can be removed.I have no idea what Leaflet version this first started manifesting with.
The text was updated successfully, but these errors were encountered: