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

Test useWindowDimensions polyfill for web #6

Open
macintoshhelper opened this issue May 16, 2020 · 1 comment
Open

Test useWindowDimensions polyfill for web #6

macintoshhelper opened this issue May 16, 2020 · 1 comment

Comments

@macintoshhelper
Copy link
Member

macintoshhelper commented May 16, 2020

It appears that web window.screen.width and window.innerWidth have some unreliable behaviour on desktop, e.g. when resizing a window to mobile width, and on a mobile device, where the viewport is artificial, but innerWidth isn't.

I've implemented a hack with a comparison operator, but this needs to be tested, and needs feedback.

This deviates from using react-native-web, which uses window.innerHeight and window.innerWidth, which in my testing seem to not render density independent pixels, as they do on React Native: https://github.com/necolas/react-native-web/blob/master/packages/react-native-web/src/exports/useWindowDimensions/index.js#L19 . So maybe this should be raised as an issue there?

@macintoshhelper
Copy link
Member Author

macintoshhelper commented May 16, 2020

I may be totally wrong and getting this confused though with another problem and react-native-web using window.innerWidth is totally fine. Checked just now and it appears to render density independent pixels (rather than native resolution) on phones, correctly.

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

No branches or pull requests

1 participant