From 7394e691d738bd66dee7f534392df902b032c244 Mon Sep 17 00:00:00 2001 From: ache Date: Sat, 2 Oct 2021 22:06:13 +0200 Subject: Zen mode CSS based --- src/js/zen.js | 28 +++------------------------- 1 file changed, 3 insertions(+), 25 deletions(-) (limited to 'src/js/zen.js') diff --git a/src/js/zen.js b/src/js/zen.js index e2e7035..05ec6b3 100644 --- a/src/js/zen.js +++ b/src/js/zen.js @@ -1,8 +1,7 @@ 'use strict'; -const articles = document.getElementsByTagName('article'); -const header = document.getElementById('side-bar'); const toggleArrow = document.getElementById('harr'); +const initValue = document.body.style.getPropertyValue('--width_panel_bis'); toggleArrow.addEventListener('click', () => { if (toggleArrow.classList.contains('hide_arrow_off')) { @@ -17,32 +16,11 @@ toggleArrow.addEventListener('click', () => { }); function hideAbout() { - if (header && !header.classList.contains('hidden')) { - header.classList.add('hidden'); - - if (articles) { - [...articles].forEach(e => { - e.classList.add('zen-mode'); - }); - } - } + document.body.style.setProperty('--width_panel_bis', '0px'); } function showAbout() { - if (header && header.classList.contains('hidden')) { - header.classList.remove('hidden'); - if (articles) { - [...articles].forEach(e => { - e.classList.remove('zen-mode'); - e.classList.add('zen-mode-disabling'); - }); - setTimeout(() => { - [...articles].forEach(e => { - e.classList.remove('zen-mode-disabling'); - }); - }, 1000); - } - } + document.body.style.setProperty('--width_panel_bis', initValue); } window.addEventListener('scroll', () => { -- cgit v1.2.3