You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
只用了pagFile和pagView,还要去销毁PAGComposition吗?销毁之后,PAGInit的PAG可以重复使用吗?
`if (!this.PAG) {
const { PAGInit } = await import("libpag");
this.PAG = await PAGInit();
}
const blob = await fetch(pagUrl).then((response) => response.blob());
const file = new window.File([blob], pagUrl.replace(/(./)([^.]+)/i, "$2"));
const pagFile = await this.PAG.PAGFile.load(file);
// 宽高的缩放比例
this.canvasDom.width = this.screenWidth;
this.canvasDom.height = pagFile.height() / (pagFile.width() / this.screenWidth);
const pagView = await this.PAG.PAGView.init(pagFile, this.canvasDom, { firstFrame: false });
pagView.setRepeatCount(1);
await pagView.play();
this.pagView = pagView;
this.pagFile = pagFile;
pagView.addListener("onAnimationEnd", async () => {
await this.destroy();
this.$emit("onAnimationEnd");
});
async destroy() {
// 销毁图片
if (this.pagFile) {
this.pagFile.destroy();
this.pagFile = null;
}
if (this.pagView) {
if (this.pagView?.pagSurface) {
await this.pagView.pagSurface.clearAll();
}
await this.pagView?.destroy();
this.pagView = null;
}
}`
Beta Was this translation helpful? Give feedback.
All reactions