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

use window.innerHeight instead of document.documentElement.clientHeight #74

Merged
merged 2 commits into from
Nov 9, 2021

Conversation

mvasin
Copy link
Owner

@mvasin mvasin commented Nov 7, 2021

After experimenting in BrowserStack with Safari on iOS versions from 10 to 15, I can confirm that document.documentElement.clientHeight is only updated after orientation change, so resize events caused by shrinking / enlarging of the URL panel don't have effect on document.documentElement.clientHeight, while window.innerHeight is being updated.

For reference (it was mentioned in #22 - the original reason to switch from window.innerHeight to document.documentElement.clientHeight, something that I revert here) - trying to extract values from document.documentElement.clientHeight and window.innerHeight won't work properly in the orientationchange event handler (the values are gibberish as the 4,5 year old bug https://bugs.webkit.org/show_bug.cgi?id=170595 is still not resolved), but iOS fires resize event after orientationchange where at least window.innerHeight looks correct, so I don't debounce orientationchange and rely on the resize event that follows.

I noticed that iOS 15 fires way more resize events on URL bar size change, so debouncing might still be necessary. But I will leave that for another update.

I also tried in Chrome on Android versions 8-11, the behavior is identical to iOS.

@vercel
Copy link

vercel bot commented Nov 7, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/vasin/react-div-100vh/6t6KMC2VszmchHrogGopCHxGinK8
✅ Preview: https://react-div-100vh-git-switch-from-clientheight-to-in-07120a-vasin.vercel.app

@Greenheart
Copy link

I tested this in [email protected] and it works for me. Thank you!

@mvasin mvasin force-pushed the switch-from-clientHeight-to-innerHeight branch from 5687262 to afe14ba Compare November 9, 2021 21:45
@mvasin mvasin merged commit 5f18055 into master Nov 9, 2021
@delete-merged-branch delete-merged-branch bot deleted the switch-from-clientHeight-to-innerHeight branch November 9, 2021 21:47
@mvasin
Copy link
Owner Author

mvasin commented Nov 9, 2021

@Greenheart thanks! published under version 0.7.0.

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.

2 participants