Browse Source

[ts] Player, set bg color on player div, not parent.

Nathan Sweet 4 years ago
parent
commit
3d2891a224
1 changed files with 5 additions and 4 deletions
  1. 5 4
      spine-ts/player/src/Player.ts

+ 5 - 4
spine-ts/player/src/Player.ts

@@ -210,10 +210,6 @@ module spine {
 			this.bgFullscreen.setFromString(config.fullScreenBackgroundColor);
 
 			this.parent.appendChild(this.create());
-			if (!config.alpha) { // Prevents a flash before the first frame is drawn.
-				let hex = config.backgroundColor;
-				this.parent.style.backgroundColor = (hex.charAt(0) == '#' ? hex : "#" + hex).substr(0, 7);
-			}
 
 			// Register a global resize handler to redraw, avoiding flicker.
 			window.addEventListener("resize", () => this.drawFrame(false));
@@ -264,6 +260,11 @@ module spine {
 			let dom = this.dom = createElement(
 				/*html*/`<div class="spine-player" style="position:relative;height:100%"><canvas class="spine-player-canvas" style="display:block;width:100%;height:100%"></canvas>${controls}</div>`);
 
+			if (!config.alpha) { // Prevents a flash before the first frame is drawn.
+				let hex = config.backgroundColor;
+				this.dom.style.backgroundColor = (hex.charAt(0) == '#' ? hex : "#" + hex).substr(0, 7);
+			}
+
 			try {
 				// Setup the OpenGL context.
 				this.canvas = findWithClass(dom, "spine-player-canvas") as HTMLCanvasElement;