Skip to content

Comments

fix(view): properly calculate offscreen state#2191

Closed
0xsven wants to merge 2 commits intopmndrs:masterfrom
0xsven:fix(view)--properly-calculate-offscreen-state
Closed

fix(view): properly calculate offscreen state#2191
0xsven wants to merge 2 commits intopmndrs:masterfrom
0xsven:fix(view)--properly-calculate-offscreen-state

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

@vercel
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.

@codesandbox-ci
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.

@abernier
Copy link
Member

@DennisSmolek
Copy link
Member

Duplicate of #1902 and implemented in v11

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.

3 participants