From 5f24de31d7c7b0252ebf12460d6dfcd9a40d739a Mon Sep 17 00:00:00 2001 From: yuki540 Date: Thu, 19 Apr 2018 15:59:01 +0900 Subject: [PATCH] =?UTF-8?q?update:=20=E3=83=9A=E3=83=BC=E3=82=B8=E3=81=AE?= =?UTF-8?q?=E3=83=AB=E3=83=BC=E3=83=86=E3=82=A3=E3=83=B3=E3=82=B0=E3=82=92?= =?UTF-8?q?=E5=AE=9F=E8=A3=85=EF=BC=88URL=E3=81=AF=E5=A4=89=E6=9B=B4?= =?UTF-8?q?=E3=81=AA=E3=81=97=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/scripts/lib/util.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/scripts/lib/util.js b/src/scripts/lib/util.js index a565519..10a06d7 100644 --- a/src/scripts/lib/util.js +++ b/src/scripts/lib/util.js @@ -90,7 +90,10 @@ export const bindNav = () => { nav.addEventListener('click', e => { e.preventDefault() const state = !(page_box.getAttribute('data-state') === 'true') + const href = e.target.getAttribute('data-href') + page_box.setAttribute('data-state', state) + showPage(href) }) }) } @@ -104,9 +107,28 @@ export const bindCloseBtn = () => { close_btn.addEventListener('click', e => { e.preventDefault() page_box.setAttribute('data-state', 'false') + hiddenPage() }) } +/** + * 対象のページを表示 + * @param : selector + */ +export const showPage = selector => { + document.querySelector(`.${ selector }`).style.display = 'block' +} + +/** + * 全てのページを非表示 + */ +export const hiddenPage = () => { + document.querySelector('.profile-page').style.display = 'none' + document.querySelector('.history-page').style.display = 'none' + document.querySelector('.memories-page').style.display = 'none' + document.querySelector('.product-page').style.display = 'none' +} + /** * ロードの開始タイミングを取得 * @param fn : コールバック関数