From 0cc95ced9575b7f35720fe48112ee985c465d092 Mon Sep 17 00:00:00 2001 From: yutent Date: Mon, 10 Apr 2023 14:33:12 +0800 Subject: [PATCH] =?UTF-8?q?layer=E4=B8=AD=E7=A7=BB=E9=99=A4=E6=8B=96?= =?UTF-8?q?=E6=8B=BD=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/layer/index.js | 44 ++++++-------------------------------------- 1 file changed, 6 insertions(+), 38 deletions(-) diff --git a/src/layer/index.js b/src/layer/index.js index 3dfb38c..2bf54ba 100644 --- a/src/layer/index.js +++ b/src/layer/index.js @@ -4,17 +4,8 @@ * @date 2023/03/06 15:17:25 */ -import { - css, - html, - Component, - bind, - unbind, - nextTick, - styleMap -} from '@bd/core' +import { css, html, Component, bind, styleMap } from '@bd/core' import '../form/input.js' -import Drag from '../drag/core.js' let uniqueInstance = null // 缓存当前打开的alert/confirm/prompt类型的弹窗 let toastInstance = null // 缓存toast的实例 @@ -40,7 +31,8 @@ class Layer extends Component { right: { type: String, attribute: false }, top: { type: String, attribute: false }, bottom: { type: String, attribute: false }, - fixed: false, + background: { type: String, attribute: false }, + 'mask-color': { type: String, attribute: false }, mask: false, 'mask-close': false, title: { type: String, default: '', attribute: false }, @@ -280,7 +272,6 @@ class Layer extends Component { ] #wrapped = false - #dragIns = null #resolve = null #reject = null @@ -296,27 +287,6 @@ class Layer extends Component { this.promise.host = this } - #toggleDrag() { - // 这3类弹层不允许拖拽 - if (UNIQUE_TYPES.includes(this.type)) { - return - } - - if (this.fixed) { - // 如之前有拖拽实例, 先销毁 - if (this.#dragIns) { - this.#dragIns.destroy() - this.#dragIns = null - } - return - } - let $title = this.$refs.box.firstElementChild - - this.#dragIns = new Drag(this.$refs.box).by($title, { - overflow: !!this.overflow - }) - } - #intercept(value) { if (this.intercept) { this.intercept(value, _ => { @@ -400,7 +370,9 @@ class Layer extends Component { } } - this.#toggleDrag() + if (this.background) { + this.$refs.box.style.backgroundColor = this.background + } this.#play() } @@ -432,10 +404,6 @@ class Layer extends Component { this.type = null this.$emit('close') } else { - // 有拖拽实例, 先销毁 - if (this.#dragIns) { - this.#dragIns.destroy() - } // 不允许多开的类型, 需要清除 if (UNIQUE_TYPES.includes(this.type)) { uniqueInstance = null