diff --git a/package.json b/package.json index 9409342..b35220e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bd/core", - "version": "1.8.2", + "version": "1.8.3", "type": "module", "description": "百搭UI组件库的核心", "main": "dist/index.js", diff --git a/src/anim.js b/src/anim.js index 7c0d8e3..bf05e40 100644 --- a/src/anim.js +++ b/src/anim.js @@ -13,15 +13,18 @@ export function animate(duration = 200, fromto = [], out = false) { direction: out ? 'reverse' : 'normal', fill: 'forwards' }) - if (out) { + return new Promise(resolve => { res.addEventListener( 'finish', _ => { - this.style.display = 'none' + if (out) { + this.style.display = 'none' + } + resolve() }, { once: true } ) - } + }) } export const MODES = { fade: [{ opacity: 0 }, { opacity: 1 }], diff --git a/src/html.js b/src/html.js index 1582dc6..7ea81a2 100644 --- a/src/html.js +++ b/src/html.js @@ -631,7 +631,7 @@ class AnimPart extends AttributePart { fromto = custom } this.element.$animate = function (out = false) { - animate.call(this, duration, fromto, out) + return animate.call(this, duration, fromto, out) } } } diff --git a/src/index.js b/src/index.js index 79ce5fc..d1d6fc4 100644 --- a/src/index.js +++ b/src/index.js @@ -91,7 +91,7 @@ export class Component extends HTMLElement { Object.defineProperty(this.prototype, '$animate', { value(out) { if (this[__mounted__]) { - animate.call(this, duration, MODES[type], out) + return animate.call(this, duration, MODES[type], out) } }, enumerable: false