nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

commit 91b591ae8f8e30239a2fe3c04bfc8050a28a3e11
parent 6dc337963a3a17c58dc363a89f632544876e713f
Author: Sergej Orlov <wladimirych@gmail.com>
Date:   Tue,  3 Jul 2018 03:25:38 +0300

[elevation profile] resize profile only when it needs to be expanded; workaround for bug in Chrome with mouseenter events

Diffstat:
Msrc/lib/leaflet.control.elevation-profile/elevation-profile.css | 11++++-------
Msrc/lib/leaflet.control.elevation-profile/index.js | 17++++++++++++-----
2 files changed, 16 insertions(+), 12 deletions(-)

diff --git a/src/lib/leaflet.control.elevation-profile/elevation-profile.css b/src/lib/leaflet.control.elevation-profile/elevation-profile.css @@ -53,8 +53,7 @@ overflow-x: scroll; overflow-y: hidden; position: relative; - margin-right: 35px; -} + } .elevation-profile-grid-label { font-family: Arial sans-serif; @@ -117,7 +116,7 @@ } .elevation-profile-cursor-hidden { - display: none; + visibility: hidden; } .elevation-profile-selection { @@ -163,13 +162,11 @@ } .elevation-profile-close { - position: absolute; - right: 10px; + float: right; + margin: 4px; width: 16px; height: 16px; background-image: url("close.png"); - margin-left: 4px; - margin-top: 4px; cursor: pointer; } diff --git a/src/lib/leaflet.control.elevation-profile/index.js b/src/lib/leaflet.control.elevation-profile/index.js @@ -253,10 +253,13 @@ const ElevationProfile = L.Class.extend({ }, _resizeGraph: function() { - this.svgWidth = this.drawingContainer.clientWidth * this.horizZoom; - this.svg.setAttribute('width', this.svgWidth + 'px'); - this.updateGraph(); - this.updateGraphSelection(); + const newSvgWidth = this.drawingContainer.clientWidth * this.horizZoom; + if (this.svgWidth < this.drawingContainer.clientWidth) { + this.svgWidth = newSvgWidth; + this.svg.setAttribute('width', this.svgWidth + 'px'); + this.updateGraph(); + this.updateGraphSelection(); + } }, _addTo: function(map) { @@ -302,7 +305,11 @@ const ElevationProfile = L.Class.extend({ svgHeight = this.svgHeight = this.drawingContainer.clientHeight; var svg = this.svg = createSvg('svg', {width: svgWidth, height: svgHeight}, this.drawingContainer); L.DomEvent.on(svg, 'mousemove', this.onSvgMouseMove, this); - L.DomEvent.on(svg, 'mouseenter', this.onSvgEnter, this); + // We should handle mouseenter event, but due to a + // bug in Chrome (https://bugs.chromium.org/p/chromium/issues/detail?id=846738) + // this event is emitted while resizing window by dragging right window frame + // which causes cursor to appeat while resizing + L.DomEvent.on(svg, 'mousemove', this.onSvgEnter, this); L.DomEvent.on(svg, 'mouseleave', this.onSvgLeave, this); L.DomEvent.on(svg, 'mousewheel', this.onSvgMouseWheel, this); this.svgDragEvents = new DragEvents(this.svg, null, {dragButtons: [0, 2]});