commit 6dc337963a3a17c58dc363a89f632544876e713f
parent 76251795ee71edbbb8eea2f79ca08770b820f175
Author: Sergej Orlov <wladimirych@gmail.com>
Date: Tue, 3 Jul 2018 02:05:24 +0300
Merge branch 'master' of /home/w/tmp/myadzel-nakarte into myadzel-profile-resize
Diffstat:
2 files changed, 20 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
@@ -6,6 +6,7 @@
bottom: 0;
z-index: 2000;
cursor: default;
+ border-top: 1px solid #ddd;
}
.elevation-profile-properties {
@@ -13,7 +14,7 @@
height: 100%;
float: left;
width: 240px;
- border-right: 1px solid #dddddd;
+ border-right: 1px solid #ddd;
}
.elevation-profile-properties table {
@@ -43,7 +44,7 @@
position: relative;
height: 100%;
float: left;
- width: 50px;
+ width: 35px;
}
.elevation-profile-drawingContainer {
@@ -52,6 +53,7 @@
overflow-x: scroll;
overflow-y: hidden;
position: relative;
+ margin-right: 35px;
}
.elevation-profile-grid-label {
@@ -115,11 +117,7 @@
}
.elevation-profile-cursor-hidden {
- visibility: hidden;
-}
-
-.elevation-profile-cursor-hidden-while-drag {
- visibility: hidden;
+ display: none;
}
.elevation-profile-selection {
@@ -166,8 +164,7 @@
.elevation-profile-close {
position: absolute;
- /*right: 0;*/
- left: 244px;
+ right: 10px;
width: 16px;
height: 16px;
background-image: url("close.png");
diff --git a/src/lib/leaflet.control.elevation-profile/index.js b/src/lib/leaflet.control.elevation-profile/index.js
@@ -246,7 +246,17 @@ const ElevationProfile = L.Class.extend({
self._addTo(map);
});
this.values = null;
+ },
+
+ _onWindowResize: function() {
+ this._resizeGraph();
+ },
+ _resizeGraph: function() {
+ this.svgWidth = this.drawingContainer.clientWidth * this.horizZoom;
+ this.svg.setAttribute('width', this.svgWidth + 'px');
+ this.updateGraph();
+ this.updateGraphSelection();
},
_addTo: function(map) {
@@ -301,6 +311,7 @@ const ElevationProfile = L.Class.extend({
this.svgDragEvents.on('drag', this.onSvgDrag, this);
this.svgDragEvents.on('click', this.onSvgClick, this);
L.DomEvent.on(svg, 'dblclick', this.onSvgDblClick, this);
+ L.DomEvent.on(window, 'resize', this._onWindowResize, this);
},
removeFrom: function(map) {
@@ -314,6 +325,7 @@ const ElevationProfile = L.Class.extend({
map.removeLayer(this.polyline);
map.removeLayer(this.trackMarker);
map.removeLayer(this.polyLineSelection);
+ L.DomEvent.off(window, 'resize', this._onWindowResize, this);
this._map = null;
this.fire('remove');
return this;
@@ -630,7 +642,7 @@ const ElevationProfile = L.Class.extend({
this.graphCursor.style.left = x + 'px';
this.graphCursorLabel.style.left = x + 'px';
if (this.drawingContainer.getBoundingClientRect().left - this.drawingContainer.scrollLeft + x +
- this.graphCursorLabel.offsetWidth >= this._container.getBoundingClientRect().right) {
+ this.graphCursorLabel.offsetWidth >= this.drawingContainer.getBoundingClientRect().right) {
L.DomUtil.addClass(this.graphCursorLabel, 'elevation-profile-cursor-label-left');
} else {
L.DomUtil.removeClass(this.graphCursorLabel, 'elevation-profile-cursor-label-left');
@@ -659,8 +671,7 @@ const ElevationProfile = L.Class.extend({
if (!this.values) {
return;
}
- var x = offestFromEvent(e).offsetX;
- var ind = (x / (this.svgWidth - 1) * (this.values.length - 1));
+ var ind = this.xToIndex(offestFromEvent(e).offsetX);
this.setCursorPosition(ind);
},