Skip to content

Commit c4db06e

Browse files
committed
skip transition when element is hidden (fix #1322)
1 parent 3175756 commit c4db06e

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/transition/transition.js

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,9 @@ p.getCssTransitionType = function (className) {
286286
// CSS transitions.
287287
document.hidden ||
288288
// explicit js-only transition
289-
(this.hooks && this.hooks.css === false)
289+
(this.hooks && this.hooks.css === false) ||
290+
// element is hidden
291+
isHidden(this.el)
290292
) {
291293
return
292294
}
@@ -336,4 +338,18 @@ p.setupCssCb = function (event, cb) {
336338
_.on(el, event, onEnd)
337339
}
338340

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

0 commit comments

Comments
 (0)