pmndrs / react-three-fiber

🇨🇭 A React renderer for Three.js
https://docs.pmnd.rs/react-three-fiber
MIT License
27.62k stars 1.6k forks source link

fix: useMeasure to include safer orientation handling #3375

Closed DennisSmolek closed 1 month ago

DennisSmolek commented 1 month ago

The previous version supported the latest screenOrientation API: https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation

But of course iOS does not support this so was throwing errors.

This adds checks to make sure the objects exists and listeners can be added.

Falls back to depreciated method orientationchange on the window: https://developer.mozilla.org/en-US/docs/Web/API/Window/orientationchange_event

If that doesn't exist either we have to pray the resize events correctly fire.

closes #3371

codesandbox-ci[bot] commented 1 month ago

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.

Latest deployment of this branch, based on commit dcef11fcd36f546b5be7b113f6b9277b6c7393dd:

Sandbox Source
example Configuration
CodyJasonBennett commented 1 month ago

I'll investigate testing this, but we should upstream and refresh use-measure. Vendored since I don't have access meanwhile.