Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Component resizes are not watched, only complete window resizes have effect #20

Open
koole opened this issue Jun 3, 2024 · 0 comments · May be fixed by #21
Open

Component resizes are not watched, only complete window resizes have effect #20

koole opened this issue Jun 3, 2024 · 0 comments · May be fixed by #21

Comments

@koole
Copy link

koole commented Jun 3, 2024

The canvas currently only resizes when the complete window resizes, not when the canvas itself changes size. This works for the example, in which the canvas is a fullscreen background, but for cases when the canvas can resize without the window resizing it results in stretched images.

It appears someone already had something in mind:
There is a "resize" prop on the canvas, which accepts an react-use-measure Options object. These options are then completely ignored, as the react-use-measure library appears to never be used anywhere, except for importing this Options type. All resizing is actually just handled by a this a window.addEventListener('resize', handleResize).

In the meantime, for anyone encountering the issue, you can fix the behaviour without changing the library by writing using your own preferred resize observer on your Canvas and then sending the following message to your worker:

workerRef.current.postMessage({
  type: "resize",
  payload: {
    width: ...,
    height: ...,
    top: ...,
    left: ...,
  },
});
@koole koole linked a pull request Jun 3, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant