From 1560a3918a31941c74ec7a112cbb2d69af56ea8d Mon Sep 17 00:00:00 2001 From: MaxxSoftware Date: Thu, 15 Nov 2012 17:16:55 +0600 Subject: [PATCH 1/2] Update select2.js DropDown displayed on the left of select-container if not fit right. --- select2.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/select2.js b/select2.js index 541c67af..0fe2e45b 100644 --- a/select2.js +++ b/select2.js @@ -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"); From ac7de2a756195ac560a88c4f0c2e2ede846da365 Mon Sep 17 00:00:00 2001 From: MaxxSoftware Date: Thu, 15 Nov 2012 17:26:19 +0600 Subject: [PATCH 2/2] Update select2.js --- select2.js | 1 + 1 file changed, 1 insertion(+) diff --git a/select2.js b/select2.js index 0fe2e45b..108a2893 100644 --- a/select2.js +++ b/select2.js @@ -892,6 +892,7 @@ the specific language governing permissions and limitations under the Apache Lic dropLeft = offset.left, enoughRoomBelow = dropTop + dropHeight <= viewportBottom, enoughRoomAbove = (offset.top - dropHeight) >= this.body().scrollTop(), + dropWidth = this.dropdown.outerWidth(false), enoughRoomOnRight = dropLeft + dropWidth <= viewPortRight, aboveNow = this.dropdown.hasClass("select2-drop-above"), bodyOffset,