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

fix(view): properly calculate offscreen state #2191

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

0xsven
Copy link

@0xsven 0xsven commented Nov 12, 2024

Why

The View component is designed to work within a Canvas that is not necessarily fullscreen. According to the documentation:

Quote from the docs:

Note that @react-three/fiber newer than ^8.1.0 is required for View to work correctly if the canvas/react three fiber root is not fullscreen.

However, I observed that View wasn’t behaving as expected. Specifically, it was checking whether the View is offscreen, rather than checking if it's outside the canvas boundaries. This caused issues when View was partially or entirely within the canvas but still considered offscreen.

Here is a codesandbox: https://codesandbox.io/p/sandbox/view-skissor-forked-w2tds3?file=%2Fsrc%2Fstyles.css%3A38%2C1
Notice how the View (red border) is not always running when inside the canvas (blue border).

What

  • Retained the existing offscreen logic for legacy CanvasSize.
  • Updated the offscreen calculation logic specifically for @react-three/fiber versions before 8.1.0.

Maybe isOffscreen should even be renamed to isOffcanvas ?

Checklist

  • Documentation updated (example) --> not needed
  • Storybook entry added (example) --> Haven't found a View story. I could create one, if that's needed...
  • Ready to be merged

Copy link

vercel bot commented Nov 12, 2024

@0xsven is attempting to deploy a commit to the Poimandres Team on Vercel.

A member of the Team first needs to authorize it.

Copy link

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

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 this pull request may close these issues.

1 participant