From 7c1347668da909e1a23337cd4ab645af92c92564 Mon Sep 17 00:00:00 2001 From: Norbert Renner Date: Fri, 21 May 2021 17:43:52 +0200 Subject: [PATCH] Prevent trailer showing on beeline button clicks --- js/plugin/Routing.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/js/plugin/Routing.js b/js/plugin/Routing.js index 78a5577..8ddb57c 100644 --- a/js/plugin/Routing.js +++ b/js/plugin/Routing.js @@ -146,22 +146,27 @@ BR.Routing = L.Routing.extend({ this._show(); } } - function hide() { + var hide = function () { if (!this._hidden && this._parent._waypoints._first) { this._hide(); } + }.bind(this._draw); + function hideOverControl(e) { + hide(); + // prevent showing trailer when clicking state buttons (causes event that propagates to map) + L.DomEvent.stopPropagation(e); } this._draw.on('enabled', function () { this._map.on('mouseout', hide, this); this._map.on('mouseover', show, this); L.DomEvent.on(this._map._controlContainer, 'mouseout', show, this); - L.DomEvent.on(this._map._controlContainer, 'mouseover', hide, this); + L.DomEvent.on(this._map._controlContainer, 'mouseover', hideOverControl, this); }); this._draw.on('disabled', function () { this._map.off('mouseout', hide, this); this._map.off('mouseover', show, this); L.DomEvent.off(this._map._controlContainer, 'mouseout', show, this); - L.DomEvent.off(this._map._controlContainer, 'mouseover', hide, this); + L.DomEvent.off(this._map._controlContainer, 'mouseover', hideOverControl, this); }); // Call show after deleting last waypoint, but hide trailer.