Jump to content

How to redraw/ update when window resize?


Recommended Posts

I have a very simple Pixijs project that display a image.

There is no animation or anything in it.

I wrote simple code to adjust the app size when the user resize the browser window.

function resize() {
  var dis = Math.min(window.innerHeight, window.innerWidth);

  app.view.width = dis;
  app.view.height = dis;

window.onresize = function(event) {

The problem I have is the canvas get resized, but the content inside it does not redraw.

Is there a function in pixi that I can call to redraw or update the canvas?

Link to comment
Share on other sites

I have never used pixi.js but I guess you're just resizing the element and not redrawing it after. I am also assuming whatever the canvas is drawing is based on these dimensions so just recall the draw function.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...