mirror of
https://gitee.com/docsifyjs/docsify.git
synced 2024-12-01 03:30:00 +08:00
feat(event): Collapse the sidebar when click outside element in the small screen
This commit is contained in:
parent
432bcfb54b
commit
9b7e5f5814
@ -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 () {
|
||||
|
Loading…
Reference in New Issue
Block a user