callbacks renamed consistently.

This commit is contained in:
Davide Tantillo 2025-04-30 16:13:25 +02:00
parent 82d09045e5
commit fe04ebeb56

View File

@ -1567,10 +1567,10 @@ class SpineWebComponentOverlay extends HTMLElement implements OverlayAttributes,
throw new Error(`"SpineWebComponentOverlay - You cannot have two spine-overlay with the same overlay-id: ${overlayId}"`); throw new Error(`"SpineWebComponentOverlay - You cannot have two spine-overlay with the same overlay-id: ${overlayId}"`);
} }
SpineWebComponentOverlay.OVERLAY_LIST.set(overlayId, this); SpineWebComponentOverlay.OVERLAY_LIST.set(overlayId, this);
// window.addEventListener("scroll", this.scrollHandler); // window.addEventListener("scroll", this.scrolledCallback);
window.addEventListener("load", this.onLoadCallback); window.addEventListener("load", this.loadedCallback);
if (this.loaded) this.onLoadCallback(); if (this.loaded) this.loadedCallback();
window.screen.orientation.addEventListener('change', this.orientationChangeCallback); window.screen.orientation.addEventListener('change', this.orientationChangedCallback);
this.intersectionObserver = new IntersectionObserver((widgets) => { this.intersectionObserver = new IntersectionObserver((widgets) => {
widgets.forEach(({ isIntersecting, target, intersectionRatio }) => { widgets.forEach(({ isIntersecting, target, intersectionRatio }) => {
@ -1599,10 +1599,10 @@ class SpineWebComponentOverlay extends HTMLElement implements OverlayAttributes,
if (this.appendedToBody && !this.noAutoParentTransform && getComputedStyle(this.parentElement!).transform === "none") { if (this.appendedToBody && !this.noAutoParentTransform && getComputedStyle(this.parentElement!).transform === "none") {
this.parentElement!.style.transform = `translateZ(0)`; this.parentElement!.style.transform = `translateZ(0)`;
} }
this.resizeObserver = new ResizeObserver(this.resizeCallback); this.resizeObserver = new ResizeObserver(this.resizedCallback);
this.resizeObserver.observe(this.parentElement!); this.resizeObserver.observe(this.parentElement!);
} else { } else {
window.addEventListener("resize", this.resizeCallback) window.addEventListener("resize", this.resizedCallback)
} }
this.widgets.forEach((widget) => { this.widgets.forEach((widget) => {
@ -1621,10 +1621,10 @@ class SpineWebComponentOverlay extends HTMLElement implements OverlayAttributes,
disconnectedCallback (): void { disconnectedCallback (): void {
const id = this.getAttribute('overlay-id'); const id = this.getAttribute('overlay-id');
if (id) SpineWebComponentOverlay.OVERLAY_LIST.delete(id); if (id) SpineWebComponentOverlay.OVERLAY_LIST.delete(id);
// window.removeEventListener("scroll", this.scrollHandler); // window.removeEventListener("scroll", this.scrolledCallback);
window.removeEventListener("load", this.onLoadCallback); window.removeEventListener("load", this.loadedCallback);
window.removeEventListener("resize", this.resizeCallback); window.removeEventListener("resize", this.resizedCallback);
window.screen.orientation.removeEventListener('change', this.orientationChangeCallback); window.screen.orientation.removeEventListener('change', this.orientationChangedCallback);
this.intersectionObserver?.disconnect(); this.intersectionObserver?.disconnect();
this.resizeObserver?.disconnect(); this.resizeObserver?.disconnect();
this.input?.dispose(); this.input?.dispose();
@ -1651,25 +1651,25 @@ class SpineWebComponentOverlay extends HTMLElement implements OverlayAttributes,
return; return;
} }
private resizeCallback = () => { private resizedCallback = () => {
this.updateCanvasSize(); this.updateCanvasSize();
} }
private orientationChangeCallback = () => { private orientationChangedCallback = () => {
this.updateCanvasSize(); this.updateCanvasSize();
// after an orientation change the scrolling changes, but the scroll event does not fire // after an orientation change the scrolling changes, but the scroll event does not fire
this.scrollHandler(); this.scrolledCallback();
} }
// right now, we scroll the canvas each frame before rendering loop, that makes scrolling on mobile waaay more smoother // right now, we scroll the canvas each frame before rendering loop, that makes scrolling on mobile waaay more smoother
// this is way scroll handler do nothing // this is way scroll handler do nothing
private scrollHandler = () => { private scrolledCallback = () => {
// this.translateCanvas(); // this.translateCanvas();
} }
private onLoadCallback = () => { private loadedCallback = () => {
this.updateCanvasSize(); this.updateCanvasSize();
this.scrollHandler(); this.scrolledCallback();
if (!this.loaded) { if (!this.loaded) {
this.parentElement!.appendChild(this); this.parentElement!.appendChild(this);
} }
@ -1701,7 +1701,7 @@ class SpineWebComponentOverlay extends HTMLElement implements OverlayAttributes,
addSlotFollowerElement (element: HTMLElement) { addSlotFollowerElement (element: HTMLElement) {
this.boneFollowersParent.appendChild(element); this.boneFollowersParent.appendChild(element);
this.resizeCallback(); this.resizedCallback();
} }
private tempFollowBoneVector = new Vector3(); private tempFollowBoneVector = new Vector3();