From 761a053b7277e86d23384ec539fc45fe1eba7765 Mon Sep 17 00:00:00 2001 From: Norbert Renner Date: Mon, 7 Aug 2017 11:32:45 +0200 Subject: [PATCH] Leaflet 1.0: revert elevation diagram touch events on desktop browsers Workaround for MrMufflon/Leaflet.Elevation#67 --- js/plugin/Elevation.js | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/js/plugin/Elevation.js b/js/plugin/Elevation.js index 12b9155..ef7fa54 100644 --- a/js/plugin/Elevation.js +++ b/js/plugin/Elevation.js @@ -7,7 +7,30 @@ BR.Elevation = L.Control.Elevation.extend({ bottom: 30, left: 60 }, - theme: "steelblue-theme" //purple + theme: "steelblue-theme" + }, + + onAdd: function (map) { + var container = L.Control.Elevation.prototype.onAdd.call(this, map); + + // revert registering touch events when touch screen detection is available and negative + // see https://github.com/MrMufflon/Leaflet.Elevation/issues/67 + if (L.Browser.touch && BR.Browser.touchScreenDetectable && !BR.Browser.touchScreen) { + + this._background.on("touchmove.drag", null). + on("touchstart.drag", null). + on("touchstart.focus", null); + L.DomEvent.off(this._container, 'touchend', this._dragEndHandler, this); + + this._background.on("mousemove.focus", this._mousemoveHandler.bind(this)). + on("mouseout.focus", this._mouseoutHandler.bind(this)). + on("mousedown.drag", this._dragStartHandler.bind(this)). + on("mousemove.drag", this._dragHandler.bind(this)); + L.DomEvent.on(this._container, 'mouseup', this._dragEndHandler, this); + + } + + return container; }, addBelow: function(map) {