Rename WebGLCanvas.canvas to WebGLCanvas.element.

This commit is contained in:
MrKBear 2023-02-03 08:51:58 +08:00
parent c8fe5854ab
commit 4cd5ebb936

View File

@ -61,7 +61,7 @@ type WebGLCanvasEventMap = {
class WebGLCanvas extends EventEmitter<WebGLCanvasEventMap> { class WebGLCanvas extends EventEmitter<WebGLCanvasEventMap> {
public readonly canvas: HTMLCanvasElement | OffscreenCanvas; public readonly element: HTMLCanvasElement | OffscreenCanvas;
public readonly context: WebGLRenderingContext | WebGL2RenderingContext; public readonly context: WebGLRenderingContext | WebGL2RenderingContext;
@ -214,7 +214,7 @@ class WebGLCanvas extends EventEmitter<WebGLCanvasEventMap> {
} }
} }
this.canvas = targetCanvas; this.element = targetCanvas;
this.context = targetContext; this.context = targetContext;
this.glVersion = targetGLVersion; this.glVersion = targetGLVersion;
this.isOffScreen = targetIsOffScreen; this.isOffScreen = targetIsOffScreen;
@ -238,12 +238,12 @@ class WebGLCanvas extends EventEmitter<WebGLCanvasEventMap> {
let hasResized = false; let hasResized = false;
if (width !== void 0) { if (width !== void 0) {
this.canvas.width = width; this.element.width = width;
hasResized = true; hasResized = true;
} }
if (height !== void 0) { if (height !== void 0) {
this.canvas.height = height; this.element.height = height;
hasResized = true; hasResized = true;
} }
@ -280,8 +280,8 @@ class WebGLCanvas extends EventEmitter<WebGLCanvasEventMap> {
} }
} }
if (targetcontainer === null && this.canvas instanceof HTMLCanvasElement) { if (targetcontainer === null && this.element instanceof HTMLCanvasElement) {
targetcontainer = this.canvas.parentElement; targetcontainer = this.element.parentElement;
} }
if (targetcontainer === null) { if (targetcontainer === null) {
@ -307,11 +307,11 @@ class WebGLCanvas extends EventEmitter<WebGLCanvasEventMap> {
this.resizeObserver = resizeObserver; this.resizeObserver = resizeObserver;
if (this.canvas instanceof HTMLElement) { if (this.element instanceof HTMLElement) {
this.canvas.style.width = "100%"; this.element.style.width = "100%";
this.canvas.style.height = "100%"; this.element.style.height = "100%";
this.canvas.style.boxSizing = "border-box"; this.element.style.boxSizing = "border-box";
this.canvas.style.display = "block"; this.element.style.display = "block";
} }
resizeObserver.observe(targetcontainer); resizeObserver.observe(targetcontainer);