Skip to content

Commit 3812267

Browse files
committed
Update position fix for chrome AND firefox
1 parent f9f6f64 commit 3812267

File tree

5 files changed

+27
-7
lines changed

5 files changed

+27
-7
lines changed

dist/select.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* ui-select
33
* http://github.com/angular-ui/ui-select
4-
* Version: 0.12.0 - 2015-07-28T18:15:47.928Z
4+
* Version: 0.12.0 - 2015-07-29T20:22:32.308Z
55
* License: MIT
66
*/
77

dist/select.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*!
22
* ui-select
33
* http://github.com/angular-ui/ui-select
4-
* Version: 0.12.0 - 2015-07-28T18:15:47.924Z
4+
* Version: 0.12.0 - 2015-07-29T20:22:32.305Z
55
* License: MIT
66
*/
77

@@ -1028,9 +1028,19 @@ uis.directive('uiSelect',
10281028
$timeout(function(){
10291029
var offset = uisOffset(element);
10301030
var offsetDropdown = uisOffset(dropdown);
1031+
var scrollTop = 0;
1032+
1033+
//Chrome, Safari
1034+
if ($document[0].body.scrollTop) {
1035+
scrollTop = $document[0].body.scrollTop;
1036+
}
1037+
//Firefox
1038+
if ($document[0].documentElement && $document[0].documentElement.scrollTop) {
1039+
scrollTop = $document[0].documentElement.scrollTop;
1040+
}
10311041

10321042
// Determine if the direction of the dropdown needs to be changed.
1033-
if (offset.top + offset.height + offsetDropdown.height > $document.find('body')[0].scrollTop + $document[0].documentElement.clientHeight) {
1043+
if (offset.top + offset.height + offsetDropdown.height > scrollTop + $document[0].documentElement.clientHeight) {
10341044
dropdown[0].style.position = 'absolute';
10351045
dropdown[0].style.top = (offsetDropdown.height * -1) + 'px';
10361046
element.addClass(directionUpClassName);

dist/select.min.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/select.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.

src/uiSelectDirective.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,19 @@ uis.directive('uiSelect',
268268
$timeout(function(){
269269
var offset = uisOffset(element);
270270
var offsetDropdown = uisOffset(dropdown);
271+
var scrollTop = 0;
272+
273+
//Chrome, Safari
274+
if ($document[0].body.scrollTop) {
275+
scrollTop = $document[0].body.scrollTop;
276+
}
277+
//Firefox
278+
if ($document[0].documentElement && $document[0].documentElement.scrollTop) {
279+
scrollTop = $document[0].documentElement.scrollTop;
280+
}
271281

272282
// Determine if the direction of the dropdown needs to be changed.
273-
if (offset.top + offset.height + offsetDropdown.height > $document.find('body')[0].scrollTop + $document[0].documentElement.clientHeight) {
283+
if (offset.top + offset.height + offsetDropdown.height > scrollTop + $document[0].documentElement.clientHeight) {
274284
dropdown[0].style.position = 'absolute';
275285
dropdown[0].style.top = (offsetDropdown.height * -1) + 'px';
276286
element.addClass(directionUpClassName);

0 commit comments

Comments
 (0)