This repository has been archived on 2023-08-30. You can view files and clone it, but cannot push or open issues/pull-requests.
bytedo
/
wcui
Archived
1
0
Fork 0
old
宇天 2019-08-28 21:11:17 +08:00
parent 03da3ad832
commit 00bf4f3d42
1 changed files with 11 additions and 3 deletions

View File

@ -90,12 +90,20 @@ export const unbind = function(dom, type, fn = noop, phase = false) {
export const clickOutside = function(dom, fn = noop) {
return bind(document, 'mousedown', ev => {
if (ev) {
if (ev.path) {
var path = ev.path.concat()
while (path.length > 3) {
if (path.shift() === dom) {
return
}
}
} else {
var target = ev.originalTarget || ev.target
console.log(target, typeof target, target.__proto__)
if (dom === target || dom.contains(target)) {
return
}
}
}
fn(ev)
})