improve dropdown open up/down mode. fixes #589
This commit is contained in:
parent
640e7066d9
commit
65af98cfed
18
select2.js
18
select2.js
@ -935,21 +935,21 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
height = this.container.outerHeight(false),
|
height = this.container.outerHeight(false),
|
||||||
width = this.container.outerWidth(false),
|
width = this.container.outerWidth(false),
|
||||||
dropHeight = this.dropdown.outerHeight(false),
|
dropHeight = this.dropdown.outerHeight(false),
|
||||||
viewPortRight = $(window).scrollLeft() + document.documentElement.clientWidth,
|
viewPortRight = $(window).scrollLeft() + $(window).width(),
|
||||||
viewportBottom = $(window).scrollTop() + document.documentElement.clientHeight,
|
viewportBottom = $(window).scrollTop() + $(window).height(),
|
||||||
dropTop = offset.top + height,
|
dropTop = offset.top + height,
|
||||||
dropLeft = offset.left,
|
dropLeft = offset.left,
|
||||||
enoughRoomBelow = dropTop + dropHeight <= viewportBottom,
|
enoughRoomBelow = dropTop + dropHeight <= viewportBottom,
|
||||||
enoughRoomAbove = (offset.top - dropHeight) >= this.body().scrollTop(),
|
enoughRoomAbove = (offset.top - dropHeight) >= this.body().scrollTop(),
|
||||||
dropWidth = this.dropdown.outerWidth(false),
|
dropWidth = this.dropdown.outerWidth(false),
|
||||||
enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight,
|
enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight,
|
||||||
aboveNow = this.dropdown.hasClass("select2-drop-above"),
|
aboveNow = this.dropdown.hasClass("select2-drop-above"),
|
||||||
bodyOffset,
|
bodyOffset,
|
||||||
above,
|
above,
|
||||||
css;
|
css;
|
||||||
|
|
||||||
// console.log("below/ droptop:", dropTop, "dropHeight", dropHeight, "sum", (dropTop+dropHeight)+" viewport bottom", viewportBottom, "enough?", enoughRoomBelow);
|
//console.log("below/ droptop:", dropTop, "dropHeight", dropHeight, "sum", (dropTop+dropHeight)+" viewport bottom", viewportBottom, "enough?", enoughRoomBelow);
|
||||||
// console.log("above/ offset.top", offset.top, "dropHeight", dropHeight, "top", (offset.top-dropHeight), "scrollTop", this.body().scrollTop(), "enough?", enoughRoomAbove);
|
//console.log("above/ offset.top", offset.top, "dropHeight", dropHeight, "top", (offset.top-dropHeight), "scrollTop", this.body().scrollTop(), "enough?", enoughRoomAbove);
|
||||||
|
|
||||||
// fix positioning when body has an offset and is not position: static
|
// fix positioning when body has an offset and is not position: static
|
||||||
|
|
||||||
@ -969,9 +969,9 @@ the specific language governing permissions and limitations under the Apache Lic
|
|||||||
if (!enoughRoomBelow && enoughRoomAbove) above = true;
|
if (!enoughRoomBelow && enoughRoomAbove) above = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!enoughRoomOnRight) {
|
if (!enoughRoomOnRight) {
|
||||||
dropLeft = offset.left + width - dropWidth;
|
dropLeft = offset.left + width - dropWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (above) {
|
if (above) {
|
||||||
dropTop = offset.top - dropHeight;
|
dropTop = offset.top - dropHeight;
|
||||||
|
Loading…
Reference in New Issue
Block a user