Skip to content

Commit 65af98c

Browse files
committed
improve dropdown open up/down mode. fixes select2#589
1 parent 640e706 commit 65af98c

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

select2.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -935,21 +935,21 @@ the specific language governing permissions and limitations under the Apache Lic
935935
height = this.container.outerHeight(false),
936936
width = this.container.outerWidth(false),
937937
dropHeight = this.dropdown.outerHeight(false),
938-
viewPortRight = $(window).scrollLeft() + document.documentElement.clientWidth,
939-
viewportBottom = $(window).scrollTop() + document.documentElement.clientHeight,
938+
viewPortRight = $(window).scrollLeft() + $(window).width(),
939+
viewportBottom = $(window).scrollTop() + $(window).height(),
940940
dropTop = offset.top + height,
941941
dropLeft = offset.left,
942942
enoughRoomBelow = dropTop + dropHeight <= viewportBottom,
943943
enoughRoomAbove = (offset.top - dropHeight) >= this.body().scrollTop(),
944-
dropWidth = this.dropdown.outerWidth(false),
945-
enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight,
944+
dropWidth = this.dropdown.outerWidth(false),
945+
enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight,
946946
aboveNow = this.dropdown.hasClass("select2-drop-above"),
947947
bodyOffset,
948948
above,
949949
css;
950950

951-
// console.log("below/ droptop:", dropTop, "dropHeight", dropHeight, "sum", (dropTop+dropHeight)+" viewport bottom", viewportBottom, "enough?", enoughRoomBelow);
952-
// console.log("above/ offset.top", offset.top, "dropHeight", dropHeight, "top", (offset.top-dropHeight), "scrollTop", this.body().scrollTop(), "enough?", enoughRoomAbove);
951+
//console.log("below/ droptop:", dropTop, "dropHeight", dropHeight, "sum", (dropTop+dropHeight)+" viewport bottom", viewportBottom, "enough?", enoughRoomBelow);
952+
//console.log("above/ offset.top", offset.top, "dropHeight", dropHeight, "top", (offset.top-dropHeight), "scrollTop", this.body().scrollTop(), "enough?", enoughRoomAbove);
953953

954954
// fix positioning when body has an offset and is not position: static
955955

@@ -969,9 +969,9 @@ the specific language governing permissions and limitations under the Apache Lic
969969
if (!enoughRoomBelow && enoughRoomAbove) above = true;
970970
}
971971

972-
if (!enoughRoomOnRight) {
973-
dropLeft = offset.left + width - dropWidth;
974-
}
972+
if (!enoughRoomOnRight) {
973+
dropLeft = offset.left + width - dropWidth;
974+
}
975975

976976
if (above) {
977977
dropTop = offset.top - dropHeight;

0 commit comments

Comments
 (0)