From 32ff04bb84d3566edee09cd7360332ad1ff7a970 Mon Sep 17 00:00:00 2001 From: William Ngan Date: Thu, 2 May 2024 01:23:07 -0700 Subject: [PATCH] get ctx before ready callback --- src/Canvas.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Canvas.ts b/src/Canvas.ts index 2097d5d6..1dc25bc3 100644 --- a/src/Canvas.ts +++ b/src/Canvas.ts @@ -78,6 +78,10 @@ export class CanvasSpace extends MultiTouchSpace { _existed = true; } + + // store canvas 2d rendering context + this._ctx = this._canvas.getContext( '2d' ); + // if we created the canvas, add it to the container and observe mutation for readiness if ( !_existed ) { const observer = new MutationObserver( ( mutations ) => { @@ -100,10 +104,6 @@ export class CanvasSpace extends MultiTouchSpace { } else { this._ready( callback ); } - - // store canvas 2d rendering context - this._ctx = this._canvas.getContext( '2d' ); - }