Use canvas instead of div container for calculating the game size
This commit is contained in:
parent
b7b2934106
commit
b52c546a8c
@ -7,6 +7,15 @@ export class HtmlUtils {
|
|||||||
throw new Error("Cannot find HTML element with id '"+id+"'");
|
throw new Error("Cannot find HTML element with id '"+id+"'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static querySelectorOrFail<T extends HTMLElement>(selector: string): T {
|
||||||
|
const elem = document.querySelector(selector);
|
||||||
|
if (elem === null) {
|
||||||
|
throw new Error("Cannot find HTML element with selector '"+selector+"'");
|
||||||
|
}
|
||||||
|
// FIXME: does not check the type of the returned type
|
||||||
|
return elem as T;
|
||||||
|
}
|
||||||
|
|
||||||
public static removeElementByIdOrFail<T extends HTMLElement>(id: string): T {
|
public static removeElementByIdOrFail<T extends HTMLElement>(id: string): T {
|
||||||
const elem = document.getElementById(id);
|
const elem = document.getElementById(id);
|
||||||
if (HtmlUtils.isHtmlElement<T>(elem)) {
|
if (HtmlUtils.isHtmlElement<T>(elem)) {
|
||||||
|
@ -212,7 +212,7 @@ class LayoutManager {
|
|||||||
* Tries to find the biggest available box of remaining space (this is a space where we can center the character)
|
* Tries to find the biggest available box of remaining space (this is a space where we can center the character)
|
||||||
*/
|
*/
|
||||||
public findBiggestAvailableArray(): {xStart: number, yStart: number, xEnd: number, yEnd: number} {
|
public findBiggestAvailableArray(): {xStart: number, yStart: number, xEnd: number, yEnd: number} {
|
||||||
const game = HtmlUtils.getElementByIdOrFail<HTMLDivElement>('game');
|
const game = HtmlUtils.querySelectorOrFail<HTMLDivElement>('#game canvas');
|
||||||
if (this.mode === LayoutMode.VideoChat) {
|
if (this.mode === LayoutMode.VideoChat) {
|
||||||
const children = document.querySelectorAll<HTMLDivElement>('div.chat-mode > div');
|
const children = document.querySelectorAll<HTMLDivElement>('div.chat-mode > div');
|
||||||
const htmlChildren = Array.from(children.values());
|
const htmlChildren = Array.from(children.values());
|
||||||
|
Loading…
Reference in New Issue
Block a user