Browse Source

skip transition when element is hidden (fix #1322)

Evan You 10 years ago
parent
commit
9139fc8458
1 changed files with 17 additions and 1 deletions
  1. 17 1
      src/transition/transition.js

+ 17 - 1
src/transition/transition.js

@@ -288,7 +288,9 @@ p.getCssTransitionType = function (className) {
     // CSS transitions.
     document.hidden ||
     // explicit js-only transition
-    (this.hooks && this.hooks.css === false)
+    (this.hooks && this.hooks.css === false) ||
+    // element is hidden
+    isHidden(this.el)
   ) {
     return
   }
@@ -338,4 +340,18 @@ p.setupCssCb = function (event, cb) {
   _.on(el, event, onEnd)
 }
 
+/**
+ * Check if an element is hidden - in that case we can just
+ * skip the transition alltogether.
+ *
+ * @param {Element} el
+ * @return {Boolean}
+ */
+
+function isHidden (el) {
+  return el.style.display === 'none' ||
+    el.style.visibility === 'hidden' ||
+    el.hidden
+}
+
 module.exports = Transition