perf(utils): optimize toggle show side tools

This commit is contained in:
XPoet 2022-11-02 22:50:34 +08:00
parent a180abc4f9
commit 4e62d7a3a9
1 changed files with 13 additions and 2 deletions

View File

@ -91,8 +91,19 @@ KEEP.initUtils = () => {
// toggle show tools list // toggle show tools list
toggleShowToolsList() { toggleShowToolsList() {
document.querySelector('.tool-toggle-show').addEventListener('click', () => { const sideToolsListDom = document.querySelector('.side-tools-list')
document.querySelector('.side-tools-list').classList.toggle('show') const toggleShowToolsDom = document.querySelector('.tool-toggle-show')
toggleShowToolsDom.addEventListener('click', (e) => {
sideToolsListDom.classList.toggle('show')
e.stopPropagation()
})
sideToolsListDom.querySelectorAll('.tools-item').forEach((item) => {
item.addEventListener('click', (e) => {
e.stopPropagation()
})
})
document.addEventListener('click', () => {
sideToolsListDom.classList.contains('show') && sideToolsListDom.classList.remove('show')
}) })
}, },