From 2a68eb4b7e77aa4bcd51f86ab40cf09dd03dbd4d Mon Sep 17 00:00:00 2001 From: Federico Rebora Date: Tue, 15 Oct 2013 10:14:48 +0100 Subject: [PATCH] Added keepInViewport option --- jquery.selectBox.js | 4 ++-- readme.md | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) 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: