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

Android Chrome, UI bar dissappears as user scrolls down leaving gap when moving page #37

Closed
samuelgoddard opened this issue Aug 4, 2020 · 8 comments
Labels
help wanted Extra attention is needed

Comments

@samuelgoddard
Copy link

Hard one to explain, but I have a bug on Android Chrome when using this library with Gatsby, everything works fine but if I navigate to a page that isn't locked to 100vh, scroll down, the android UI bar at the bottom on the screen dissappears, when I nav back to another page from my fixed header, the 100vh page is calculated with the OS UI bar even though it isn't there, leaving a gap at the bottom.

An example can be seen here - https://prb-architects.netlify.app/ - if you navigate to a project from the carousel on the home page, scroll down, then click back in the fixed header at the top, you'll see the bug.

Is there any way anyone knows a workaround for this? It's fine in every mobile browser except Chrome Android

Thanks in advance,
Sam

@mvasin
Copy link
Owner

mvasin commented Aug 5, 2020

Hi Sam! We rely on document.documentElement.clientHeight || window.innerHeight to determine the height. Could you try to debug these values to see if it's a browser issue or the app issue? A link to a minimal reproduction (as little code and dependencies as possible just to reproduce the issue) would also help.

@sandren
Copy link

sandren commented Aug 29, 2020

I've encountered this behavior as well, but I think it is preferable to have a small gap where the address bar used to be than for the initial content to be completely out of view.

You can use this demo created by the Chromium team to help troubleshoot issues with document.documentElement.clientHeight values. Alternatively you could change the position of the element you are trying to resize to fixed, which will make it responsive to viewport changes, but that might not be what you want either.

@Blagoj5
Copy link

Blagoj5 commented Oct 14, 2020

I'm having the same exact problem for some reason it leaves a gap when i scroll up (when the navbar from chrome disappears). And my element is set to fixed with: top: 0 left:0 bottom: 0 properties (btw im doing a side drawer)

@mvasin mvasin added the help wanted Extra attention is needed label Oct 14, 2020
@kirill-kruchkov
Copy link

Hello! When I faced a similar issue, I've done some research and found that this trick suggests to rely purely on window.innerHeight. @mvasin is there any reason I'm missing to prefer documentElement.clientHeight over window.innerHeight?

@rinorzek
Copy link

+1 , any updates?

@davilatk
Copy link

+1 , any updates?

@mvasin
Copy link
Owner

mvasin commented Nov 7, 2021

Hi all,

I did some testing on BrowserStack (thanks for OSS sponsorship, BrowserStack!), window.innerHeight does look superior to documentElement.clientHeight - I only noticed document.documentElement.clientHeight being updated on after rotation, while window.innerHeight is updated on the URL bar height change.

It's a bit bizarre to change it from document.documentElement.clientHeight to window.innerHeight (see #22) and now back (in #74), but seems like going for document.documentElement.clientHeight was a mistake.

I published #74 as [email protected], please try it out.

@mvasin
Copy link
Owner

mvasin commented Nov 9, 2021

I received a few comments confirming that swapping document.documentElement.clientHeight for window.innerHeight works well, so I published version 0.7.0 with the update. Closing the issue for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

7 participants