parent
724b3732a0
commit
0ee7ddc6a1
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@bd/core",
|
"name": "@bd/core",
|
||||||
"version": "1.8.2",
|
"version": "1.8.3",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"description": "百搭UI组件库的核心",
|
"description": "百搭UI组件库的核心",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
|
|
|
@ -13,15 +13,18 @@ export function animate(duration = 200, fromto = [], out = false) {
|
||||||
direction: out ? 'reverse' : 'normal',
|
direction: out ? 'reverse' : 'normal',
|
||||||
fill: 'forwards'
|
fill: 'forwards'
|
||||||
})
|
})
|
||||||
if (out) {
|
return new Promise(resolve => {
|
||||||
res.addEventListener(
|
res.addEventListener(
|
||||||
'finish',
|
'finish',
|
||||||
_ => {
|
_ => {
|
||||||
|
if (out) {
|
||||||
this.style.display = 'none'
|
this.style.display = 'none'
|
||||||
|
}
|
||||||
|
resolve()
|
||||||
},
|
},
|
||||||
{ once: true }
|
{ once: true }
|
||||||
)
|
)
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
export const MODES = {
|
export const MODES = {
|
||||||
fade: [{ opacity: 0 }, { opacity: 1 }],
|
fade: [{ opacity: 0 }, { opacity: 1 }],
|
||||||
|
|
|
@ -631,7 +631,7 @@ class AnimPart extends AttributePart {
|
||||||
fromto = custom
|
fromto = custom
|
||||||
}
|
}
|
||||||
this.element.$animate = function (out = false) {
|
this.element.$animate = function (out = false) {
|
||||||
animate.call(this, duration, fromto, out)
|
return animate.call(this, duration, fromto, out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -91,7 +91,7 @@ export class Component extends HTMLElement {
|
||||||
Object.defineProperty(this.prototype, '$animate', {
|
Object.defineProperty(this.prototype, '$animate', {
|
||||||
value(out) {
|
value(out) {
|
||||||
if (this[__mounted__]) {
|
if (this[__mounted__]) {
|
||||||
animate.call(this, duration, MODES[type], out)
|
return animate.call(this, duration, MODES[type], out)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
enumerable: false
|
enumerable: false
|
||||||
|
|
Loading…
Reference in New Issue