Skip to content

Commit effb36b

Browse files
committed
Fix #110
1 parent 6ef42cb commit effb36b

File tree

7 files changed

+37
-9
lines changed

7 files changed

+37
-9
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "jquery-selectric",
33
"description": "Fast, simple and light jQuery plugin to customize HTML selects",
4-
"version": "1.9.5",
4+
"version": "1.9.6",
55
"keywords": [
66
"select",
77
"selectbox",

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "selectric",
3-
"version": "1.9.5",
3+
"version": "1.9.6",
44
"main": "public/jquery.selectric.js",
55
"title": "jQuery Selectric",
66
"author": {

public/jquery.selectric.js

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
* /,'
1010
* /'
1111
*
12-
* Selectric ϟ v1.9.5 (Mar 13 2016) - http://lcdsantos.github.io/jQuery-Selectric/
12+
* Selectric ϟ v1.9.6 (Mar 24 2016) - http://lcdsantos.github.io/jQuery-Selectric/
1313
*
1414
* Copyright (c) 2016 Leonardo Santos; MIT License
1515
*
@@ -469,7 +469,21 @@
469469

470470
// Detect is the options box is inside the window
471471
function _isInViewport() {
472-
$outerWrapper.toggleClass(_this.classes.above, $outerWrapper.offset().top + $outerWrapper.outerHeight() + itemsHeight > $win.scrollTop() + $win.height());
472+
var scrollTop = $win.scrollTop();
473+
var winHeight = $win.height();
474+
var uiPosX = $outerWrapper.offset().top;
475+
var uiHeight = $outerWrapper.outerHeight();
476+
477+
var fitsDown = (uiPosX + uiHeight + itemsHeight) <= (scrollTop + winHeight);
478+
var fitsAbove = (uiPosX - itemsHeight) > scrollTop;
479+
480+
// If it does not fit below, only render it
481+
// above it fit's there.
482+
// It's acceptable that the user needs to
483+
// scroll the viewport to see the cut off UI
484+
var renderAbove = !fitsDown && fitsAbove;
485+
486+
$outerWrapper.toggleClass(_this.classes.above, renderAbove);
473487
}
474488

475489
// Close the select options box

public/jquery.selectric.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

public/selectric.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*======================================
2-
Selectric v1.9.5
2+
Selectric v1.9.6
33
======================================*/
44

55
.selectric-wrapper {

selectric.jquery.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "selectric",
3-
"version": "1.9.5",
3+
"version": "1.9.6",
44
"title": "jQuery Selectric",
55
"author": {
66
"name": "Leonardo Santos",

src/jquery.selectric.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,21 @@
452452

453453
// Detect is the options box is inside the window
454454
function _isInViewport() {
455-
$outerWrapper.toggleClass(_this.classes.above, $outerWrapper.offset().top + $outerWrapper.outerHeight() + itemsHeight > $win.scrollTop() + $win.height());
455+
var scrollTop = $win.scrollTop();
456+
var winHeight = $win.height();
457+
var uiPosX = $outerWrapper.offset().top;
458+
var uiHeight = $outerWrapper.outerHeight();
459+
460+
var fitsDown = (uiPosX + uiHeight + itemsHeight) <= (scrollTop + winHeight);
461+
var fitsAbove = (uiPosX - itemsHeight) > scrollTop;
462+
463+
// If it does not fit below, only render it
464+
// above it fit's there.
465+
// It's acceptable that the user needs to
466+
// scroll the viewport to see the cut off UI
467+
var renderAbove = !fitsDown && fitsAbove;
468+
469+
$outerWrapper.toggleClass(_this.classes.above, renderAbove);
456470
}
457471

458472
// Close the select options box

0 commit comments

Comments
 (0)