fix(webui): preserve viewport position through keyboard rotation
This commit is contained in:
1 parent
d07fac940f
commit
eec1d13aca
4 files changed
+22
-4
No files matched your search
@@ -15,8 +15,13 @@ export function useAppViewport() {
|
||||
// user's magnified viewport. Resume fitting when the scale returns to 1.
|
||||
if (viewport.scale !== 1) return;
|
||||
root.style.setProperty("--app-viewport-height", `${viewport.height}px`);
|
||||
root.style.setProperty("--app-viewport-top", `${viewport.offsetTop}px`);
|
||||
// WebKit can report a negative offset after rotating a focused PWA.
|
||||
// Do not move the navigation above the top edge with that overscroll.
|
||||
root.style.setProperty("--app-viewport-top", `${Math.max(0, viewport.offsetTop)}px`);
|
||||
root.classList.add("visual-viewport");
|
||||
// Only the keyboard's shortest layouts need a scrollable composer.
|
||||
// Normal layouts must let the command and mention palettes overflow.
|
||||
root.classList.toggle("short-visual-viewport", viewport.height < 240);
|
||||
};
|
||||
update();
|
||||
viewport.addEventListener("resize", update);
|
||||
@@ -25,6 +30,7 @@ export function useAppViewport() {
|
||||
viewport.removeEventListener("resize", update);
|
||||
viewport.removeEventListener("scroll", update);
|
||||
root.classList.remove("visual-viewport");
|
||||
root.classList.remove("short-visual-viewport");
|
||||
root.style.removeProperty("--app-viewport-height");
|
||||
root.style.removeProperty("--app-viewport-top");
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user