优化动画封装

pull/1/head 1.8.2
yutent 2023-04-04 12:04:17 +08:00
parent d7918768b9
commit 724b3732a0
3 changed files with 8 additions and 15 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@bd/core",
"version": "1.8.1",
"version": "1.8.2",
"type": "module",
"description": "百搭UI组件库的核心",
"main": "dist/index.js",

View File

@ -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)
}
}
}

View File

@ -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()