diff options
Diffstat (limited to 'client')
| -rw-r--r-- | client/splash/index.js | 3 | ||||
| -rw-r--r-- | client/splash/modal.js | 19 |
2 files changed, 19 insertions, 3 deletions
diff --git a/client/splash/index.js b/client/splash/index.js index 322ed0ff..e247b7f5 100644 --- a/client/splash/index.js +++ b/client/splash/index.js @@ -30,8 +30,9 @@ function build() { } function bind() { + document.querySelector('.slogan').addEventListener('click', modal.close) toArray(document.querySelectorAll('.aboutLink')).forEach(el => { - el.addEventListener('click', modal.open) + el.addEventListener('click', modal.toggle) }) document.querySelector('.about .inner').addEventListener('click', e => e.stopPropagation()) document.querySelector('.about').addEventListener('click', modal.close) diff --git a/client/splash/modal.js b/client/splash/modal.js index d5a63d75..47d26c06 100644 --- a/client/splash/modal.js +++ b/client/splash/modal.js @@ -1,10 +1,25 @@ -export function open() { +let isOpen = false + +export function toggle(e) { + if (isOpen) close(e) + else open(e) +} + +export function open(e) { + if (e) e.preventDefault() + if (isOpen) return const el = document.querySelector('.about') + document.body.classList.add('modalOpen') el.classList.add('open') + isOpen = true } -export function close() { +export function close(e) { + if (e) e.preventDefault() + if (!isOpen) return const el = document.querySelector('.about') + document.body.classList.remove('modalOpen') el.classList.remove('open') + isOpen = false } |
