@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.
@@ -22,25 +22,38 @@ const gameOuterStyle: React.CSSProperties = {
22
22
 
23
23
  /**
24
24
  * Track actual visible height via VisualViewport API.
25
- * On iOS Safari, 100dvh does NOT shrink when the keyboard opens (unlike
26
- * PWA/Capacitor where the platform runs). VisualViewport.height gives
27
- * the real available space, achieving the same behavior: game content
28
- * compresses instead of the page being pushed off-screen.
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
- setHeight(`${vv.height}px`);
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 () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@littlepartytime/dev-kit",
3
- "version": "1.22.2",
3
+ "version": "1.22.3",
4
4
  "description": "Development toolkit CLI for Little Party Time game developers",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",