Problems with canvas inside a Webview in React Native

Asked

Viewed 163 times

1

Why when changing the height > 100 and width > 640 on the canvas inside a Webview in React Nenable, nothing more and drawing?

//funciona 
...
canvas.width  = 640;
canvas.height = 100;
ctx.drawImage(img, 0, 0);
...

//não  funciona 
...
canvas.width  = 1024;
canvas.height = 768;
ctx.drawImage(img, 0, 0);
...

1 answer

1

I was able to solve by changing the dimensions at the end of the DOM loading, as in the example below.

window.onload = () => {
   canvas.width  = 1024;
   canvas.height = 768;
   ctx.drawImage(img, 0, 0);
   // ...
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.