-
Notifications
You must be signed in to change notification settings - Fork 11
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
Mobile: Status bar scrolls out of view when the soft keyboard is open #50
Comments
How would you define "status bar" here? A grid window can be any size and any position in the screen rectangle. |
I think my solution for the iOS native app (back when that was supported) was to resize the screen rectangle to "above the keyboard" when the keyboard was open. This gives more or less the right effect, unless the game doesn't fit in that smaller space. Then things get ugly. I'm afraid I'm not up on what kind of HTML layout shenanigans you need to make this happen on mobile browsers. |
I think this would be involved. https://developer.mozilla.org/en-US/docs/Web/API/Visual_Viewport_API |
I did some experimenting with the visual viewport API on iOS today; it didn't go well.
I think it's possible that by clever application of debouncing we could scroll the body up and the buffer down to compensate, but we're inherently fighting the platform here. I think the "right" thing to do as far as the web platform is concerned is to:
|
After some more experimentation today, I learned that even When opening the keyboard, iOS Safari doesn't honor |
Fixes erkyrath#50. When the iOS soft keyboard opens, the "resize" event doesn't fire on the window (the "layout viewport" hasn't changed) but the the "visual viewport" resizes. https://developer.mozilla.org/en-US/docs/Web/API/Visual_Viewport_API https://developers.google.com/web/updates/2017/09/visual-viewport-api In this commit, we respond to changes in the size of the visual viewport, moving the top-most grid window down to the top of the visual viewport. Since the vast majority of games have just one grid window at the top of the screen, this does what we want. I set this code to only slide around the top-most grid window when the game UI sets spacing to 0, because non-zero spacing introduces a visual border around the windows, with the background color coming from the #gameport, but if we slide a grid window down on top of a buffer window, it can't bring its spacing with it. (This is OK by me, because I'm really only doing this for Parchment's sake, which does set spacing 0. Lectrote uses spacing 4, which is fine; it won't be affected by these changes. I tested this code with spacing 4, showing that it has no effect, and with spacing 0, on iOS 15.) I'd previously experimented with re-measuring the window and using the visual viewport's dimensions for the computation, but we don't actually want to resize the primary buffer window smaller; that will screw up its scroll position, and, worse, it will look really weird to the user. Furthermore, we can't actually trust visualViewport.height on iOS 15; we can know where the top of the viewport is, but the 20px URL bar may overlay the bottom. See erkyrath#50 for a screenshot of the buggy results.
Fixes erkyrath#50. When the iOS soft keyboard opens, the "resize" event doesn't fire on the window (the "layout viewport" hasn't changed) but the the "visual viewport" resizes. https://developer.mozilla.org/en-US/docs/Web/API/Visual_Viewport_API https://developers.google.com/web/updates/2017/09/visual-viewport-api In this commit, we respond to changes in the size of the visual viewport, moving the top-most grid window down to the top of the visual viewport. Since the vast majority of games have just one grid window at the top of the screen, this does what we want. I set this code to only slide around the top-most grid window when the game UI sets spacing to 0, because non-zero spacing introduces a visual border around the windows, with the background color coming from the #gameport, but if we slide a grid window down on top of a buffer window, it can't bring its spacing with it. (This is OK by me, because I'm really only doing this for Parchment's sake, which does set spacing 0. Lectrote uses spacing 4, which is fine; it won't be affected by these changes. I tested this code with spacing 4, showing that it has no effect, and with spacing 0, on iOS 15.) I'd previously experimented with re-measuring the window and using the visual viewport's dimensions for the computation, but we don't actually want to resize the primary buffer window smaller; that will screw up its scroll position, and, worse, it will look really weird to the user. Furthermore, we can't actually trust visualViewport.height on iOS 15; we can know where the top of the viewport is, but the 20px URL bar may overlay the bottom. See erkyrath#50 for a screenshot of the buggy results.
I got it, and filed a PR on both branches of glkote. |
Go to https://eblong.com/zarf/glk/glkote/sample-demo.html on iOS. Click the input line to open the keyboard.
Actual: When the keyboard is open, the status bar ("The Kitchen") scrolls out of view.
Expected: The status bar should appear floating at the top of the visual viewport.
The text was updated successfully, but these errors were encountered: