8000 Merge pull request #966 from djsmith42/master · ITCSsDeveloper/select2@3fe95ac · GitHub
Skip to content

Commit 3fe95ac

Browse files
committed
Merge pull request select2#966 from djsmith42/master
Fix mask height/width when document is shorter than window
2 parents 66860b2 + 953b6f2 commit 3fe95ac

1 file changed

Lines changed: 9 additions & 6 deletions

File tree

select2.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,9 +1121,7 @@ the specific language governing permissions and limitations under the Apache Lic
11211121
this.dropdown.attr("id", "select2-drop");
11221122

11231123
// show the elements
1124-
mask.css({
1125-
width: document.documentElement.scrollWidth,
1126-
height: document.documentElement.scrollHeight});
1124+
mask.css(_makeMaskCss());
11271125
mask.show();
11281126
this.dropdown.show();
11291127
this.positionDropdown();
@@ -1136,14 +1134,19 @@ the specific language governing permissions and limitations under the Apache Lic
11361134
var that = this;
11371135
this.container.parents().add(window).each(function () {
11381136
$(this).bind(resize+" "+scroll+" "+orient, function (e) {
1139-
$("#select2-drop-mask").css({
1140-
width:document.documentElement.scrollWidth,
1141-
height:document.documentElement.scrollHeight});
1137+
$("#select2-drop-mask").css(_makeMaskCss());
11421138
that.positionDropdown();
11431139
});
11441140
});
11451141

11461142
this.focusSearch();
1143+
1144+
function _makeMaskCss() {
1145+
return {
1146+
width : Math.max(document.documentElement.scrollWidth, $(window).width()),
1147+
height : Math.max(document.documentElement.scrollHeight, $(window).height())
1148+
}
1149+
}
11471150
},
11481151

11491152
// abstract

0 commit comments

Comments
 (0)