Skip to content

Commit

Permalink
Propagate event reason in loading.ts [onProgress], to ensure event.de…
Browse files Browse the repository at this point in the history
…tail.reason is accessible on ModelViewerElement (#4701)
  • Loading branch information
rsleyland authored Mar 11, 2024
1 parent 6c16da3 commit df6306f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion packages/model-viewer/src/features/loading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ export const LoadingMixin = <T extends Constructor<ModelViewerElementBase>>(

[$onProgress] = (event: Event) => {
const progress = (event as any).detail.totalProgress;
const reason = (event as any).detail.reason;

if (progress === 1.0) {
this[$updateProgressBar].flush();
Expand All @@ -373,7 +374,7 @@ export const LoadingMixin = <T extends Constructor<ModelViewerElementBase>>(
this[$updateProgressBar](progress);

this.dispatchEvent(
new CustomEvent('progress', {detail: {totalProgress: progress}}));
new CustomEvent('progress', {detail: {totalProgress: progress, reason}}));
};

[$shouldAttemptPreload](): boolean {
Expand Down

0 comments on commit df6306f

Please sign in to comment.