Sfoglia il codice sorgente

Merge pull request #842 from baiyaaaaa/master

fix ie bounding top bug
杨奕 8 anni fa
parent
commit
56126c9a8f
2 ha cambiato i file con 12 aggiunte e 3 eliminazioni
  1. 1 1
      build/cooking.demo.js
  2. 11 2
      src/utils/popper.js

+ 1 - 1
build/cooking.demo.js

@@ -91,5 +91,5 @@ if (process.env.NODE_ENV === 'production') {
 
 cooking.add('vue.preserveWhitespace', false);
 cooking.add('output.chunkFilename', 'element.[id].[chunkhash:7].js');
-cooking.add('output.filename', 'element.[name].[chunkhash:7].js');
+cooking.add('output.filename', 'element.[name].[hash:7].js');
 module.exports = cooking.resolve();

+ 11 - 2
src/utils/popper.js

@@ -1148,13 +1148,22 @@
      */
     function getBoundingClientRect(element) {
         var rect = element.getBoundingClientRect();
+
+        // whether the IE version is lower than 11
+        var isIE = navigator.userAgent.indexOf("MSIE") != -1;
+
+        // fix ie document bouding top always 0 bug
+        var rectTop = isIE && element.tagName === 'HTML'
+            ? -element.scrollTop
+            : rect.top;
+
         return {
             left: rect.left,
-            top: rect.top,
+            top: rectTop,
             right: rect.right,
             bottom: rect.bottom,
             width: rect.right - rect.left,
-            height: rect.bottom - rect.top
+            height: rect.bottom - rectTop
         };
     }