diff --git a/spine-ts/spine-webcomponents/example/tutorial.html b/spine-ts/spine-webcomponents/example/tutorial.html index b8ae49c2b..bc9287393 100644 --- a/spine-ts/spine-webcomponents/example/tutorial.html +++ b/spine-ts/spine-webcomponents/example/tutorial.html @@ -280,12 +280,20 @@
+
- If you want to manually size the Spine widget, specify the width and height attributes in pixels (without the "px" unit). + By default, the widget occupy zero width and height. + If you want to manually size the Spine widget, you can style the component using the style or class attribute, which provides more styling options.
-
- If you prefer, you can style the component using the style attribute, which provides more styling options.
diff --git a/spine-ts/spine-webcomponents/src/SpineWebComponentSkeleton.ts b/spine-ts/spine-webcomponents/src/SpineWebComponentSkeleton.ts index 8d1497eae..c9644e1ce 100644 --- a/spine-ts/spine-webcomponents/src/SpineWebComponentSkeleton.ts +++ b/spine-ts/spine-webcomponents/src/SpineWebComponentSkeleton.ts @@ -875,7 +875,7 @@ export class SpineWebComponentSkeleton extends HTMLElement implements Disposable * @returns The `HTMLElement` where the widget is hosted. */ public getHostElement (): HTMLElement { - return (this.width <= 0 || this.width <= 0) && !this.getAttribute("style") + return (this.width <= 0 || this.width <= 0) && !this.getAttribute("style") && !this.getAttribute("class") ? this.parentElement! : this; } @@ -1075,22 +1075,13 @@ export class SpineWebComponentSkeleton extends HTMLElement implements Disposable } private render (): void { - let width; - let height; - if (this.width === -1 || this.height === -1) { - width = "0"; - height = "0"; - } else { - width = `${this.width}px` - height = `${this.height}px` - } + let noSize = (!this.getAttribute("style") && !this.getAttribute("class")); this.root.innerHTML = ` `;