update: ナビボタンのマウスイベントを監視する処理を実装

This commit is contained in:
yuki540 2018-04-18 17:49:42 +09:00
parent f081f07613
commit c644125354
2 changed files with 21 additions and 0 deletions

View File

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

View File

@ -67,6 +67,26 @@ export const setRingSize = () => {
top_page__wrap.style.transform = `scale(${ per })`
}
/**
* ナビゲーションボタンホバー時のイベント監視
*/
export const bindNav = () => {
const navs = document.querySelectorAll('.top-page__global-nav a')
navs.forEach((nav, key) => {
/* mouseover ------------------------------------------------- */
nav.addEventListener('mouseover', e => {
const color = e.target.getAttribute('data-color')
top_page.setAttribute('data-color', color)
})
/* mouseout -------------------------------------------------- */
nav.addEventListener('mouseout', e => {
top_page.setAttribute('data-color', '')
})
})
}
/**
* ロードの開始タイミングを取得
* @param fn : コールバック関数