Updated approach for resolving scrollbar issue in legend

This commit is contained in:
Rowan Winsemius 2015-06-30 21:59:20 +10:00
parent 43da2c32a3
commit 9bfb6d854e
2 changed files with 8 additions and 8 deletions

4
dist/leaflet.css vendored
View File

@ -326,6 +326,10 @@
color: #333;
background: #fff;
}
.leaflet-control-layers-scrollbar {
overflow-y: scroll;
padding-right: 5px;
}
.leaflet-control-layers-selector {
margin-top: 2px;
position: relative;

View File

@ -248,15 +248,11 @@ L.Control.Layers = L.Control.extend({
_expand: function () {
L.DomUtil.addClass(this._container, 'leaflet-control-layers-expanded');
var getLegendDiv = document.getElementsByClassName('leaflet-control-layers-list')[0];
var legendHeight = getLegendDiv.clientHeight;
var getMap = document.getElementById('map');
var controlHeight = getMap.clientHeight - 40;
if (controlHeight < legendHeight)
var acceptableHeight = this._map._size.y - (this._container.offsetTop * 4);
if (acceptableHeight < this._form.clientHeight)
{
getLegendDiv.style.height = controlHeight + 'px';
getLegendDiv.style.overflowY = 'scroll';
getLegendDiv.style.paddingRight = '10px';
L.DomUtil.addClass(this._form, 'leaflet-control-layers-scrollbar');
this._form.style.height = acceptableHeight + 'px';
}
},