|
@@ -886,11 +886,13 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
|
height = this.container.outerHeight(false),
|
|
|
width = this.container.outerWidth(false),
|
|
|
dropHeight = this.dropdown.outerHeight(false),
|
|
|
+ viewPortRight = $(window).scrollLeft() + document.documentElement.clientWidth,
|
|
|
viewportBottom = $(window).scrollTop() + document.documentElement.clientHeight,
|
|
|
dropTop = offset.top + height,
|
|
|
dropLeft = offset.left,
|
|
|
enoughRoomBelow = dropTop + dropHeight <= viewportBottom,
|
|
|
enoughRoomAbove = (offset.top - dropHeight) >= this.body().scrollTop(),
|
|
|
+ enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight,
|
|
|
aboveNow = this.dropdown.hasClass("select2-drop-above"),
|
|
|
bodyOffset,
|
|
|
above,
|
|
@@ -917,6 +919,10 @@ the specific language governing permissions and limitations under the Apache Lic
|
|
|
if (!enoughRoomBelow && enoughRoomAbove) above = true;
|
|
|
}
|
|
|
|
|
|
+ if (!enoughRoomOnRight) {
|
|
|
+ dropLeft = offset.left + width - dropWidth;
|
|
|
+ }
|
|
|
+
|
|
|
if (above) {
|
|
|
dropTop = offset.top - dropHeight;
|
|
|
this.container.addClass("select2-drop-above");
|