Skip to content

Commit 9139fc8

Browse files
committed
skip transition when element is hidden (fix vuejs#1322)
1 parent 930c7f0 commit 9139fc8

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/transition/transition.js

+17-1
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,9 @@ p.getCssTransitionType = function (className) {
288288
// CSS transitions.
289289
document.hidden ||
290290
// explicit js-only transition
291-
(this.hooks && this.hooks.css === false)
291+
(this.hooks && this.hooks.css === false) ||
292+
// element is hidden
293+
isHidden(this.el)
292294
) {
293295
return
294296
}
@@ -338,4 +340,18 @@ p.setupCssCb = function (event, cb) {
338340
_.on(el, event, onEnd)
339341
}
340342

343+
/**
344+
* Check if an element is hidden - in that case we can just
345+
* skip the transition alltogether.
346+
*
347+
* @param {Element} el
348+
* @return {Boolean}
349+
*/
350+
351+
function isHidden (el) {
352+
return el.style.display === 'none' ||
353+
el.style.visibility === 'hidden' ||
354+
el.hidden
355+
}
356+
341357
module.exports = Transition

0 commit comments

Comments
 (0)