diff --git a/jquery.selectBox.js b/jquery.selectBox.js index 6820f96..aebccc1 100755 --- a/jquery.selectBox.js +++ b/jquery.selectBox.js @@ -460,8 +460,8 @@ , scrollPos = $(window).scrollTop() , heightToTop = pos.top - scrollPos , heightToBottom = $(window).height() - ( heightToTop + controlHeight ) - , posTop = heightToTop > heightToBottom - , top = posTop + , posTop = (heightToTop > heightToBottom) && (settings.keepInViewport == null ? true : settings.keepInViewport) + , top = posTop ? pos.top - optionsHeight + borderTopWidth + topPositionCorrelation : pos.top + controlHeight - borderBottomWidth - bottomPositionCorrelation; diff --git a/readme.md b/readme.md index 70131b2..b5c0466 100755 --- a/readme.md +++ b/readme.md @@ -53,6 +53,7 @@ $('select').selectBox({ | topPositionCorrelation | `0` | Integer | Will be plused to top position if droplist will be show at the top | | bottomPositionCorrelation | `0` | Integer | Will be substracted from top position if droplist will be shown at the bottom | | hideOnWindowScroll | `true` | Boolean | If false then showed droplist will not hide itself on window scroll event | +| keepInViewport | `true` | Boolean | If set to false, the droplist will be always open towards the bottom | To specify settings after the init, use this syntax: