Fix widget using overlay before overlay webcomponent is fully upgraded.

This commit is contained in:
Davide Tantillo 2024-10-03 09:23:48 +02:00
parent 6fa149756a
commit 8cc5a2ba5e

View File

@ -530,7 +530,7 @@ export class SpineWebComponentWidget extends HTMLElement implements Disposable,
throw new Error("You cannot attach a disposed widget");
};
this.overlay.addWidget(this);
customElements.whenDefined("spine-overlay").then(() => this.overlay.addWidget(this));
if (!this.manualStart && !this.started) {
this.start();
}
@ -538,12 +538,10 @@ export class SpineWebComponentWidget extends HTMLElement implements Disposable,
}
disconnectedCallback (): void {
this.loadingPromise?.then(() => {
const index = this.overlay.skeletonList.indexOf(this);
if (index !== -1) {
this.overlay.skeletonList.splice(index, 1);
}
});
const index = this.overlay.skeletonList.indexOf(this);
if (index !== -1) {
this.overlay.skeletonList.splice(index, 1);
}
this.debugDragDiv?.remove();
}
@ -573,7 +571,8 @@ export class SpineWebComponentWidget extends HTMLElement implements Disposable,
}
this.started = true;
this.loadingPromise = this.loadSkeleton();
this.loadingPromise = customElements.whenDefined("spine-overlay").then(() => this.loadSkeleton());
this.loadingPromise.then(() => {
this.loading = false;
});