Skip to content

Commit

Permalink
feat(event): Collapse the sidebar when click outside element in the s…
Browse files Browse the repository at this point in the history
…mall screen
  • Loading branch information
QingWei-Li committed Apr 9, 2017
1 parent 432bcfb commit 9b7e5f5
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions src/core/event/sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,22 @@ const title = dom.$.title
* Toggle button
*/
export function btn (el) {
const toggle = () => dom.body.classList.toggle('close')
const toggle = _ => dom.body.classList.toggle('close')

el = dom.getNode(el)
dom.on(el, 'click', toggle)
dom.on(el, 'click', e => {
e.stopPropagation()
toggle()
})

const sidebar = dom.getNode('.sidebar')

dom.on(sidebar, 'click', () => {
isMobile && toggle()
setTimeout(() => getAndActive(sidebar, true, true), 0)
})
isMobile && dom.on(dom.body, 'click', _ =>
dom.body.classList.contains('close') && toggle()
)
dom.on(sidebar, 'click', _ =>
setTimeout((_ => getAndActive(sidebar, true, true), 0))
)
}

export function sticky () {
Expand Down

0 comments on commit 9b7e5f5

Please sign in to comment.