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

优化clickOutside,兼容shadowdom

old
宇天 2019-08-28 20:55:15 +08:00
parent 5c82a42bb4
commit 03da3ad832
2 changed files with 16 additions and 5 deletions

View File

@ -38,7 +38,10 @@
&.shift { &.shift {
transition: all 0.5s ease-out; transition: all 0.5s ease-out;
} }
&.scale {
transform: scale(1.01);
transition: transform 0.1s linear;
}
&.blur { &.blur {
backdrop-filter: blur(5px); backdrop-filter: blur(5px);
} }
@ -666,6 +669,13 @@ class Layer {
this._handlMask = clickOutside(this.root.children[1], ev => { this._handlMask = clickOutside(this.root.children[1], ev => {
if (this.props.maskClose) { if (this.props.maskClose) {
this.close() this.close()
} else {
if (UNIQUE_TYPES.includes(this.props.type)) {
this.root.children[1].classList.toggle('scale', true)
setTimeout(_ => {
this.root.children[1].classList.remove('scale')
}, 100)
}
} }
}) })
} }

View File

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