Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ var winMtds = L.control.window(map)
| closeButton | Render close button? | true | Boolean |
| className | Sets container class to style window. | 'control-window' | String |
| maxWidth | Sets maximum width of window container in pixels. | 600 | Number |
| maxHeight | Sets maximum height of window container in pixels. | undefined | Number |
| prompt | JSON object for prompt buttons. | undefined | JSON ```{callback: ..., action: ..., buttonAction: ..., buttonOK: ..., buttonCancel: ...}``` |
| prompt.callback | Function to run after OK button is clicked. | undefined | e.g. ```function(){alert('hello')}``` |
| prompt.action | Function to run after ACTION button is clicked. | undefined | e.g. ```function(){alert('I\'ll do something')}``` |
Expand Down
14 changes: 9 additions & 5 deletions src/L.Control.Window.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,16 @@ L.Control.Window = L.Control.extend({
margin += this._containerPromptButtons.offsetHeight-20
}

var el = L.DomUtil.get(this.options.element)
var rect = el.getBoundingClientRect();
var height = rect.bottom -rect.top;
var maxHeight = this.options.maxHeight;
if (maxHeight==undefined) {
var el = L.DomUtil.get(this.options.element)
var rect = el.getBoundingClientRect();
var height = rect.bottom -rect.top;

var maxHeight = height - margin;
this._containerContent.setAttribute('style','max-height:'+maxHeight+'px')
maxHeight = height - margin;
}
this._container.setAttribute('style','max-height:'+maxHeight+'px;overflow:hidden;max-width:'+this.options.maxWidth+'px');
this._containerContent.setAttribute('style','max-height:'+(maxHeight-60)+'px')
},
close : function(){
this.hide();
Expand Down