Skip to content

Commit cd5a78c

Browse files
committed
added new settings
topPositionCorrelation - (int) will be plused to top position if droplist will be show at the top; bottomPositionCorrelation - (int) will be substracted from top position if droplist will be shown at the bottom; hideOnWindowScroll - (bool) if false then showed droplist will not hide on window scroll.
1 parent 1a0755a commit cd5a78c

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

jquery.selectBox.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@
9393
if (!$(window).data('selectBox-bindings')) {
9494
$(window)
9595
.data('selectBox-bindings', true)
96-
.bind('scroll.selectBox', this.hideMenus)
96+
.bind('scroll.selectBox', (settings.hideOnWindowScroll) ? this.hideMenus : $.noop)
9797
.bind('resize.selectBox', this.hideMenus);
9898
}
9999

@@ -452,6 +452,8 @@
452452

453453
// Get proper variables for keeping options in viewport
454454
var pos = control.offset()
455+
, topPositionCorrelation = (settings.topPositionCorrelation) ? settings.topPositionCorrelation : 0
456+
, bottomPositionCorrelation = (settings.bottomPositionCorellation) ? settings.bottomPositionCorellation : 0
455457
, optionsHeight = options.outerHeight()
456458
, controlHeight = control.outerHeight()
457459
, maxHeight = parseInt(options.css('max-height'))
@@ -460,8 +462,8 @@
460462
, heightToBottom = $(window).height() - ( heightToTop + controlHeight )
461463
, posTop = heightToTop > heightToBottom
462464
, top = posTop
463-
? pos.top - optionsHeight + borderTopWidth
464-
: pos.top + controlHeight - borderBottomWidth;
465+
? pos.top - optionsHeight + borderTopWidth + topPositionCorrelation
466+
: pos.top + controlHeight - borderBottomWidth - bottomPositionCorrelation;
465467

466468

467469
// If the height to top and height to bottom are less than the max-height

0 commit comments

Comments
 (0)