Merge pull request #3571 from rowanwins/layerControlScroll

Scrollbar for layers control with too many layers
This commit is contained in:
Vladimir Agafonkin 2015-06-30 15:25:06 +03:00
commit c38159d986
2 changed files with 10 additions and 0 deletions

4
dist/leaflet.css vendored
View File

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

View File

@ -248,6 +248,12 @@ L.Control.Layers = L.Control.extend({
_expand: function () { _expand: function () {
L.DomUtil.addClass(this._container, 'leaflet-control-layers-expanded'); L.DomUtil.addClass(this._container, 'leaflet-control-layers-expanded');
var acceptableHeight = this._map._size.y - (this._container.offsetTop * 4);
if (acceptableHeight < this._form.clientHeight)
{
L.DomUtil.addClass(this._form, 'leaflet-control-layers-scrollbar');
this._form.style.height = acceptableHeight + 'px';
}
}, },
_collapse: function () { _collapse: function () {