From 32249cc7f0d8eff88465e92996e813a6121c2a3e Mon Sep 17 00:00:00 2001 From: Igor Vaynberg Date: Thu, 31 Jan 2013 16:45:26 -0800 Subject: [PATCH] better support orientation change on mobile. #782 --- select2.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/select2.js b/select2.js index 281f15f5..025f19da 100644 --- a/select2.js +++ b/select2.js @@ -981,6 +981,7 @@ the specific language governing permissions and limitations under the Apache Lic var cid = this.containerId, scroll = "scroll." + cid, resize = "resize."+cid, + orient = "orientationchange."+cid, mask; this.clearDropdownAlignmentPreference(); @@ -1020,7 +1021,7 @@ the specific language governing permissions and limitations under the Apache Lic // attach listeners to events that can change the position of the container and thus require // the position of the dropdown to be updated as well so it does not come unglued from the container this.container.parents().add(window).each(function () { - $(this).bind(resize+" "+scroll, function (e) { + $(this).bind(resize+" "+scroll+" "+orient, function (e) { $("#select2-drop-mask").css({ width:document.documentElement.scrollWidth, height:document.documentElement.scrollHeight}); @@ -1037,10 +1038,11 @@ the specific language governing permissions and limitations under the Apache Lic var cid = this.containerId, scroll = "scroll." + cid, - resize = "resize."+cid; + resize = "resize."+cid, + orient = "orientationchange."+cid; // unbind event listeners - this.container.parents().add(window).each(function () { $(this).unbind(scroll).unbind(resize); }); + this.container.parents().add(window).each(function () { $(this).unbind(scroll).unbind(resize).unbind(orient); }); this.clearDropdownAlignmentPreference();