From ea5e803159bcf21b673e45a8642a9007e2812637 Mon Sep 17 00:00:00 2001 From: pastalian Date: Tue, 20 Oct 2020 01:21:41 +0900 Subject: [PATCH] Improve DOM editing --- assets/js/helper/fadeinout.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/assets/js/helper/fadeinout.js b/assets/js/helper/fadeinout.js index f511c7e..231dc0e 100644 --- a/assets/js/helper/fadeinout.js +++ b/assets/js/helper/fadeinout.js @@ -11,7 +11,7 @@ var fadeOut = function(node, duration) { requestAnimationFrame(tick); } else { node.style.opacity = ''; - node.style.display = 'none'; + node.classList.add('hide'); } }); } @@ -19,10 +19,8 @@ var fadeOut = function(node, duration) { var fadeIn = function (node, duration) { if (getComputedStyle(node).display !== 'none') return; - if (node.style.display === 'none') { - node.style.display = ''; - } else { - node.style.display = 'block'; + if (node.classList.contains('hide')) { + node.classList.remove('hide'); } node.style.opacity = 0;