@littlepartytime/dev-kit 1.22.2 → 1.22.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/webapp/pages/Mobile.tsx +20 -7
- package/package.json +1 -1
|
@@ -22,25 +22,38 @@ const gameOuterStyle: React.CSSProperties = {
|
|
|
22
22
|
|
|
23
23
|
/**
|
|
24
24
|
* Track actual visible height via VisualViewport API.
|
|
25
|
-
*
|
|
26
|
-
* PWA
|
|
27
|
-
*
|
|
28
|
-
*
|
|
25
|
+
*
|
|
26
|
+
* On iOS Safari (non-PWA), 100dvh does NOT shrink when the keyboard opens.
|
|
27
|
+
* We use visualViewport.height to detect the keyboard and override the
|
|
28
|
+
* container height only while it's open. When the keyboard closes, we
|
|
29
|
+
* revert to 100dvh so Safari toolbar/address bar changes don't leave
|
|
30
|
+
* a dead zone at the bottom.
|
|
29
31
|
*/
|
|
30
32
|
function useViewportHeight(): string {
|
|
31
33
|
const [height, setHeight] = useState('100dvh');
|
|
34
|
+
const initialHeight = useRef(0);
|
|
32
35
|
|
|
33
36
|
useEffect(() => {
|
|
34
37
|
const vv = window.visualViewport;
|
|
35
38
|
if (!vv) return;
|
|
36
39
|
|
|
40
|
+
// Capture the full viewport height on first load (no keyboard)
|
|
41
|
+
initialHeight.current = vv.height;
|
|
42
|
+
|
|
43
|
+
const KEYBOARD_THRESHOLD = 100; // px — if viewport shrinks by more than this, keyboard is open
|
|
44
|
+
|
|
37
45
|
const update = () => {
|
|
38
|
-
// Pin to top: counteract Safari scrolling the page up
|
|
39
46
|
window.scrollTo(0, 0);
|
|
40
|
-
|
|
47
|
+
const shrunk = initialHeight.current - vv.height;
|
|
48
|
+
if (shrunk > KEYBOARD_THRESHOLD) {
|
|
49
|
+
// Keyboard is open: use exact pixel height so content compresses
|
|
50
|
+
setHeight(`${vv.height}px`);
|
|
51
|
+
} else {
|
|
52
|
+
// Keyboard is closed: use 100dvh to fill the screen fully
|
|
53
|
+
setHeight('100dvh');
|
|
54
|
+
}
|
|
41
55
|
};
|
|
42
56
|
|
|
43
|
-
update();
|
|
44
57
|
vv.addEventListener('resize', update);
|
|
45
58
|
vv.addEventListener('scroll', update);
|
|
46
59
|
return () => {
|