-
-
Notifications
You must be signed in to change notification settings - Fork 575
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
Fix zoom behavior on mobile #935
Conversation
This reverts commit 528164c.
How it breaks if it's exact same code: var height = window.visualViewport.height;
var scale = window.visualViewport.scale;
height = Math.round(height * scale); and this is the same: var scale = window.visualViewport.scale;
var height = Math.round(window.visualViewport.height * scale); You just do this in two steps instead of one. |
Ok it seems you added this line for no reason: var newHeight = Math.round(window.visualViewport.height * newScale); this code was on in first commit. |
OK, so you wanted only those lines changed, i.e.: var scale = window.visualViewport.scale;
var height = Math.round(window.visualViewport.height * scale);
callback(height);
window.visualViewport.addEventListener('resize', function() {
var newHeight = window.visualViewport.height;
var newScale = window.visualViewport.scale;
if (height !== newHeight) {
height = Math.round(newHeight * newScale);
callback(height);
}
}); This way we are comparing a scaled height with a non-scaled height (unless I'm missing something!!) with var scale = window.visualViewport.scale;
var height = Math.round(window.visualViewport.height * scale);
callback(height);
window.visualViewport.addEventListener('resize', function() {
var newHeight = window.visualViewport.height;
if (height !== newHeight) {
var newScale = window.visualViewport.scale;
height = Math.round(newHeight * newScale);
callback(height);
}
}); Storing the scaling factors in the |
Yea, you're right, but your code also have the same bug you compare scaled with non-scaled. It is triggering every time. |
Updated the PR. Now it should all be OK. Tested again on Android 13. |
Change preliminarily discussed in #859.
The change fixes an erratic behavior when zooming in with a mobile web browser.
The terminal height was changed accordingly to a change in the visual viewport, but without considering the scale factor. This led, e.g., to a terminal area half the expected one for a 2X zoom level.
The fix does not alter the resizing behavior at constant scale factor for the appearing and disappearing of a virtual keyboard.