فهرست منبع

tweak how mask is created to remove jitter. fixes #1574

Igor Vaynberg 11 سال پیش
والد
کامیت
e162a4802c
2فایلهای تغییر یافته به همراه16 افزوده شده و 27 حذف شده
  1. 6 13
      select2.css
  2. 10 14
      select2.js

+ 6 - 13
select2.css

@@ -114,25 +114,18 @@ Version: @@ver@@ Timestamp: @@timestamp@@
     cursor: pointer;
 }
 
-.select2-drop-undermask {
-    border: 0;
-    margin: 0;
-    padding: 0;
-    position: absolute;
-    left: 0;
-    top: 0;
-    z-index: 9998;
-    background-color: transparent;
-    filter: alpha(opacity=0);
-}
-
 .select2-drop-mask {
     border: 0;
     margin: 0;
     padding: 0;
-    position: absolute;
+    position: fixed;
     left: 0;
     top: 0;
+    min-height: 100%;
+    min-width: 100%;
+    height: auto;
+    width: auto;
+    opacity: 0;
     z-index: 9998;
     /* styles required for IE to work */
     background-color: #fff;

+ 10 - 14
select2.js

@@ -1262,7 +1262,7 @@ the specific language governing permissions and limitations under the Apache Lic
                         if (self.opts.selectOnBlur) {
                             self.selectHighlighted({noFocus: true});
                         }
-                        self.close();
+                        self.close({focus:false});
                         e.preventDefault();
                         e.stopPropagation();
                     }
@@ -1279,9 +1279,7 @@ the specific language governing permissions and limitations under the Apache Lic
             this.dropdown.attr("id", "select2-drop");
 
             // show the elements
-            maskCss=_makeMaskCss();
-
-            mask.css(maskCss).show();
+            mask.show();
 
             this.dropdown.show();
             this.positionDropdown();
@@ -1293,18 +1291,11 @@ the specific language governing permissions and limitations under the Apache Lic
             var that = this;
             this.container.parents().add(window).each(function () {
                 $(this).on(resize+" "+scroll+" "+orient, function (e) {
-                    var maskCss=_makeMaskCss();
-                    $("#select2-drop-mask").css(maskCss);
                     that.positionDropdown();
                 });
             });
 
-            function _makeMaskCss() {
-                return {
-                    width  : Math.max(document.documentElement.scrollWidth,  $(window).width()),
-                    height : Math.max(document.documentElement.scrollHeight, $(window).height())
-                }
-            }
+
         },
 
         // abstract
@@ -1835,11 +1826,16 @@ the specific language governing permissions and limitations under the Apache Lic
         },
 
         // single
-        close: function () {
+        close: function (params) {
             if (!this.opened()) return;
             this.parent.close.apply(this, arguments);
+
+            params = params || {focus: true};
             this.focusser.removeAttr("disabled");
-            this.focusser.focus();
+
+            if (params.focus) {
+                this.focusser.focus();
+            }
         },
 
         // single