update: 閉じるボタンの処理を実装

This commit is contained in:
yuki540 2018-04-19 14:02:31 +09:00
parent 480815723f
commit 205566eec9
2 changed files with 22 additions and 1 deletions

View File

@ -9,6 +9,7 @@ import './components/app.tag'
// init // init
util.setRingSize() util.setRingSize()
util.bindNav() util.bindNav()
util.bindCloseBtn()
// loading // loading
util.startLoading(() => { util.startLoading(() => {

View File

@ -10,6 +10,7 @@ const end_animation = document.querySelector('.end-animation')
const end_animation__end = document.querySelector('.end-animation .window img') const end_animation__end = document.querySelector('.end-animation .window img')
const top_page = document.querySelector('.top-page') const top_page = document.querySelector('.top-page')
const top_page__wrap = document.querySelector('.top-page .wrap') const top_page__wrap = document.querySelector('.top-page .wrap')
const page_box = document.querySelector('.page-box')
/** /**
* 画像のプリロード * 画像のプリロード
@ -68,7 +69,7 @@ export const setRingSize = () => {
} }
/** /**
* ナビゲーションボタンホバー時のイベント監視 * ナビゲーションボタンイベント監視
*/ */
export const bindNav = () => { export const bindNav = () => {
const navs = document.querySelectorAll('.top-page__global-nav a') const navs = document.querySelectorAll('.top-page__global-nav a')
@ -84,6 +85,25 @@ export const bindNav = () => {
nav.addEventListener('mouseout', e => { nav.addEventListener('mouseout', e => {
top_page.setAttribute('data-color', '') top_page.setAttribute('data-color', '')
}) })
/* click ----------------------------------------------------- */
nav.addEventListener('click', e => {
e.preventDefault()
const state = !(page_box.getAttribute('data-state') === 'true')
page_box.setAttribute('data-state', state)
})
})
}
/**
* ページを閉じるボタンのイベント監視
*/
export const bindCloseBtn = () => {
const close_btn = document.querySelector('.page-box__close-btn')
close_btn.addEventListener('click', e => {
e.preventDefault()
page_box.setAttribute('data-state', 'false')
}) })
} }