Răsfoiți Sursa

use boundingClientRect for svg element hidden detection (fix #2396)

Evan You 10 ani în urmă
părinte
comite
59868bbe92
1 a modificat fișierele cu 12 adăugiri și 5 ștergeri
  1. 12 5
      src/transition/transition.js

+ 12 - 5
src/transition/transition.js

@@ -379,9 +379,16 @@ p.setupCssCb = function (event, cb) {
  */
 
 function isHidden (el) {
-  return !(
-    el.offsetWidth ||
-    el.offsetHeight ||
-    el.getClientRects().length
-  )
+  if (/svg$/.test(el.namespaceURI)) {
+    // SVG elements do not have offset(Width|Height)
+    // so we need to check the client rect
+    var rect = el.getBoundingClientRect()
+    return !(rect.width || rect.height)
+  } else {
+    return !(
+      el.offsetWidth ||
+      el.offsetHeight ||
+      el.getClientRects().length
+    )
+  }
 }