[ts][webcomponents] Fix overlay div size when body is smaller than document.

This commit is contained in:
Davide Tantillo 2025-05-22 13:01:06 +02:00
parent 7ac6ae6987
commit 7366fcfa4e

View File

@ -863,8 +863,7 @@ export class SpineWebComponentOverlay extends HTMLElement implements OverlayAttr
this.div!.style.height = height + "px"; this.div!.style.height = height + "px";
} else { } else {
if (this.hasCssTweakOff()) { if (this.hasCssTweakOff()) {
// this case lags if scrolls or position fixed // this case lags if scrolls or position fixed. Users should never use tweak off
// users should never use tweak off, unless the parent container has already a transform
this.div!.style.width = this.parentElement!.clientWidth + "px"; this.div!.style.width = this.parentElement!.clientWidth + "px";
this.div!.style.height = this.parentElement!.clientHeight + "px"; this.div!.style.height = this.parentElement!.clientHeight + "px";
this.canvas.style.transform = `translate(${-this.overflowLeftSize}px,${-this.overflowTopSize}px)`; this.canvas.style.transform = `translate(${-this.overflowLeftSize}px,${-this.overflowTopSize}px)`;
@ -890,7 +889,7 @@ export class SpineWebComponentOverlay extends HTMLElement implements OverlayAttr
// this means that during zoom it might occurs that the div would be resized // this means that during zoom it might occurs that the div would be resized
// rounded 1px more making a scrollbar appear // rounded 1px more making a scrollbar appear
private getPageSize () { private getPageSize () {
return document.body.getBoundingClientRect(); return document.documentElement.getBoundingClientRect();
} }
private lastViewportWidth = 0; private lastViewportWidth = 0;