commit 44139f485e2dc4aa80394979c44cc9d2df04595a
parent 641063de797c56b3ddb9bdbf8d89b0a9475b5b3c
Author: myadzel <myadzel@gmail.com>
Date: Thu, 24 May 2018 12:39:54 +0300
resize altitude profile on window resize
Diffstat:
2 files changed, 25 insertions(+), 3 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 {
@@ -52,6 +53,7 @@
overflow-x: scroll;
overflow-y: hidden;
position: relative;
+ display: block;
}
.elevation-profile-grid-label {
@@ -115,11 +117,11 @@
}
.elevation-profile-cursor-hidden {
- visibility: hidden;
+ display: none;
}
.elevation-profile-cursor-hidden-while-drag {
- visibility: hidden;
+ display: none;
}
.elevation-profile-selection {
diff --git a/src/lib/leaflet.control.elevation-profile/index.js b/src/lib/leaflet.control.elevation-profile/index.js
@@ -247,6 +247,26 @@ const ElevationProfile = L.Class.extend({
});
this.values = null;
+ this._setupWindowResize();
+ },
+
+ _setupWindowResize: function() {
+ let onWindowResize = this._onWindowResize.bind(this);
+ L.DomEvent.off(window, 'resize', onWindowResize, this);
+ L.DomEvent.on(window, 'resize', onWindowResize, this);
+ L.DomEvent.on(this, 'remove', function() {
+ L.DomEvent.off(window, 'resize', onWindowResize, this);
+ });
+ },
+
+ _onWindowResize: function() {
+ this._resizeGraph();
+ },
+
+ _resizeGraph: function() {
+ this.svgWidth = this.drawingContainer.clientWidth * this.horizZoom;
+ this.svg.setAttribute('width', this.svgWidth + 'px');
+ this.updateGraph();
},
_addTo: function(map) {