Skip to content

Commit a12fdf4

Browse files
author
Marc J. Schmidt
committed
Merge pull request marcj#138 from Fuffi/master
Added keepInViewport option
2 parents 90b997a + 2a68eb4 commit a12fdf4

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

jquery.selectBox.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,8 +460,8 @@
460460
, scrollPos = $(window).scrollTop()
461461
, heightToTop = pos.top - scrollPos
462462
, heightToBottom = $(window).height() - ( heightToTop + controlHeight )
463-
, posTop = heightToTop > heightToBottom
464-
, top = posTop
463+
, posTop = (heightToTop > heightToBottom) && (settings.keepInViewport == null ? true : settings.keepInViewport)
464+
, top = posTop
465465
? pos.top - optionsHeight + borderTopWidth + topPositionCorrelation
466466
: pos.top + controlHeight - borderBottomWidth - bottomPositionCorrelation;
467467

readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ $('select').selectBox({
5353
| topPositionCorrelation | `0` | Integer | Will be plused to top position if droplist will be show at the top |
5454
| bottomPositionCorrelation | `0` | Integer | Will be substracted from top position if droplist will be shown at the bottom |
5555
| hideOnWindowScroll | `true` | Boolean | If false then showed droplist will not hide itself on window scroll event |
56+
| keepInViewport | `true` | Boolean | If set to false, the droplist will be always open towards the bottom |
5657

5758

5859
To specify settings after the init, use this syntax:

0 commit comments

Comments
 (0)