From 724b3732a0739f7428b79cd4e2cc2b743571f24d Mon Sep 17 00:00:00 2001 From: yutent Date: Tue, 4 Apr 2023 12:04:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=8A=A8=E7=94=BB=E5=B0=81?= =?UTF-8?q?=E8=A3=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/html.js | 7 ++----- src/index.js | 14 +++++--------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index 6a4950f..9409342 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@bd/core", - "version": "1.8.1", + "version": "1.8.2", "type": "module", "description": "百搭UI组件库的核心", "main": "dist/index.js", diff --git a/src/html.js b/src/html.js index f7f2397..1582dc6 100644 --- a/src/html.js +++ b/src/html.js @@ -630,11 +630,8 @@ class AnimPart extends AttributePart { if (custom) { fromto = custom } - this.element.$anim = { - el: this.element, - start(out = false) { - animate.call(this.el, duration, fromto, out) - } + this.element.$animate = function (out = false) { + animate.call(this, duration, fromto, out) } } } diff --git a/src/index.js b/src/index.js index 73b1056..79ce5fc 100644 --- a/src/index.js +++ b/src/index.js @@ -88,14 +88,10 @@ export class Component extends HTMLElement { static parseAnim() { if (this.hasOwnProperty('animation')) { let { type = 'fade', duration } = this.animation - Object.defineProperty(this.prototype, '$anim', { - get() { - return { - start: out => { - if (this[__mounted__]) { - animate.call(this, duration, MODES[type], out) - } - } + Object.defineProperty(this.prototype, '$animate', { + value(out) { + if (this[__mounted__]) { + animate.call(this, duration, MODES[type], out) } }, enumerable: false @@ -175,7 +171,7 @@ export class Component extends HTMLElement { } connectedCallback() { - if (this.$anim) { + if (this.$animate) { this.style.display = 'none' } this.#init()