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

This commit is contained in:
Nathan Sweet 2021-06-20 15:13:41 -04:00
parent b044bdbf47
commit 3d2891a224

View File

@ -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;