From 03da3ad832c5c8bfdbfb37c892a9a08ba3689370 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=87=E5=A4=A9?= Date: Wed, 28 Aug 2019 20:55:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96clickOutside,=E5=85=BC?= =?UTF-8?q?=E5=AE=B9shadowdom?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layer/next.wc | 12 +++++++++++- src/utils.js | 9 +++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/layer/next.wc b/src/layer/next.wc index 877a939..949d62b 100644 --- a/src/layer/next.wc +++ b/src/layer/next.wc @@ -38,7 +38,10 @@ &.shift { transition: all 0.5s ease-out; } - + &.scale { + transform: scale(1.01); + transition: transform 0.1s linear; + } &.blur { backdrop-filter: blur(5px); } @@ -666,6 +669,13 @@ class Layer { this._handlMask = clickOutside(this.root.children[1], ev => { if (this.props.maskClose) { 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) + } } }) } diff --git a/src/utils.js b/src/utils.js index 06afcfd..e3b339f 100644 --- a/src/utils.js +++ b/src/utils.js @@ -90,10 +90,11 @@ export const unbind = function(dom, type, fn = noop, phase = false) { export const clickOutside = function(dom, fn = noop) { return bind(document, 'mousedown', ev => { if (ev) { - var target = ev.target - - if (dom === target || dom.contains(target)) { - return + var path = ev.path.concat() + while (path.length > 3) { + if (path.shift() === dom) { + return + } } } fn(ev)