Fix sidebar animation (#14)

This commit is contained in:
cinwell.li 2016-11-29 23:09:59 +08:00 committed by GitHub
commit 19bf043cf8
6 changed files with 132 additions and 80 deletions

View file

@ -77,7 +77,12 @@ export function activeLink (dom, activeParent) {
export function bindToggle (dom) {
dom = typeof dom === 'object' ? dom : document.querySelector(dom)
if (!dom) return
const main = document.querySelector('main')
const body = document.body
dom.addEventListener('click', () => main.classList.toggle('close'))
dom.addEventListener('click', () => body.classList.toggle('close'))
if (!/mobile/i.test(navigator.userAgent)) return
document.querySelector('aside').addEventListener('click', event => {
body.classList.toggle('close')
})
}