diff --git a/mobile/capacitor.config.json b/mobile/capacitor.config.json index afd4b3d..cb11352 100644 --- a/mobile/capacitor.config.json +++ b/mobile/capacitor.config.json @@ -17,7 +17,7 @@ "offsetForKeyboardInsetBug": false }, "Keyboard": { - "resize": "none" + "resize": "native" }, "SplashScreen": { "launchShowDuration": 900, diff --git a/server/public/home.html b/server/public/home.html index 1a25816..91c24b9 100644 --- a/server/public/home.html +++ b/server/public/home.html @@ -1112,7 +1112,7 @@
- // juggling here — we only tag so CSS can make small native-only tweaks if needed. (function(){ try{ var C=window.Capacitor; if(!C||!C.isNativePlatform||!C.isNativePlatform()) return; var p=(C.getPlatform&&C.getPlatform())||''; var r=document.documentElement; r.classList.add('native-app'); if(p) r.classList.add('native-'+p); - // Keyboard — DEVICE-INDEPENDENT: the real keyboard overlap is (layout viewport height - visible viewport - // height), read from the VisualViewport API. No per-device factor. We prefer that; only if the WebView - // doesn't reflect the keyboard in VisualViewport do we fall back to the plugin's reported height. - function kbFromVV(){ var vv=window.visualViewport; if(!vv) return 0; return Math.max(0, Math.round(document.documentElement.clientHeight - vv.height - vv.offsetTop)); } - function applyKb(px){ px=Math.max(0,Math.round(px)); r.style.setProperty('--kb',px+'px'); document.body.classList.toggle('kb-open',px>4); if(px>4){ var b=document.getElementById('msgs'); if(b) b.scrollTop=b.scrollHeight; } } - // TEMP one-time debug readout (remove once logic is locked): shows the raw signals at the top of screen. - var dbg=document.createElement('div'); var lastRaw=null; - dbg.style.cssText='position:fixed;left:0;right:0;top:0;z-index:2147483647;background:rgba(0,0,0,.82);color:#0f0;font:11px/1.35 monospace;padding:3px 6px;text-align:center;pointer-events:none;'; - function rd(){ var vv=window.visualViewport; dbg.textContent='kbRaw='+(lastRaw==null?'-':Math.round(lastRaw))+' innerH='+window.innerHeight+' clientH='+document.documentElement.clientHeight+' vvH='+(vv?Math.round(vv.height):'-')+' vvTop='+(vv?Math.round(vv.offsetTop):'-')+' dpr='+window.devicePixelRatio+' -> vvKb='+kbFromVV(); } - if(document.body){ document.body.appendChild(dbg); } else { document.addEventListener('DOMContentLoaded', function(){ document.body.appendChild(dbg); }); } - if(window.visualViewport){ ['resize','scroll'].forEach(function(ev){ window.visualViewport.addEventListener(ev, function(){ var k=kbFromVV(); if(k>20) applyKb(k); rd(); }); }); } - var KB=C.Plugins&&C.Plugins.Keyboard; - if(KB && KB.addListener){ - KB.addListener('keyboardWillShow', function(info){ lastRaw=info&&info.keyboardHeight; rd(); setTimeout(function(){ var k=kbFromVV(); if(k>20){ applyKb(k); } else { var raw=lastRaw||0, dpr=window.devicePixelRatio||1; applyKb(raw>window.innerHeight?raw/dpr:raw); } rd(); }, 60); }); - KB.addListener('keyboardWillHide', function(){ lastRaw=0; applyKb(0); rd(); }); + // Keyboard — DEVICE-INDEPENDENT & self-adjusting. resize:native already shrinks the WebView by the + // keyboard height, so the composer only needs the RESIDUAL lift = (layout viewport height - visible + // viewport height) — the sliver still under the keyboard's prediction/accessory bar. Read live from + // the VisualViewport API so the composer follows the keyboard smoothly. No per-device constants. + if(window.visualViewport){ + var vv=window.visualViewport; + var applyKb=function(){ + var kb=Math.max(0, Math.round(document.documentElement.clientHeight - vv.height - vv.offsetTop)); + r.style.setProperty('--kb', kb+'px'); + document.body.classList.toggle('kb-open', kb>4); + var b=document.getElementById('msgs'); if(b) b.scrollTop=b.scrollHeight; + }; + vv.addEventListener('resize', applyKb); vv.addEventListener('scroll', applyKb); } - rd(); }catch(_){} })();