diff --git a/server/public/home.html b/server/public/home.html index f2e6999..c955340 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: with resize:none the native layer does NOTHING, so we lift the composer ourselves by the - // reported keyboard height (× a tunable factor). This is fully web-controllable now — if the lift is a - // touch high/low we adjust KB_LIFT here and redeploy, no rebuild. - var KB_LIFT=1.0; // fraction of keyboardHeight to raise the composer by (calibrate via web if needed) - var KB=C.Plugins&&C.Plugins.Keyboard; - if(KB && KB.addListener){ - KB.addListener('keyboardWillShow', function(info){ var h=Math.round(((info&&info.keyboardHeight)||0)*KB_LIFT); r.style.setProperty('--kb', h+'px'); document.body.classList.add('kb-open'); }); - KB.addListener('keyboardDidShow', function(){ var b=document.getElementById('msgs'); if(b) b.scrollTop=b.scrollHeight; }); - KB.addListener('keyboardWillHide', function(){ r.style.setProperty('--kb','0px'); document.body.classList.remove('kb-open'); }); + // Keyboard: with resize:none the WebView never resizes, so we raise the composer to sit on the keyboard + // using the VisualViewport API — the ACTUAL amount the visible area shrinks by. This is measured, not the + // plugin's reported height (which overshot), so it lands exactly on the keyboard. + if(window.visualViewport){ + var vv=window.visualViewport; + var onVV=function(){ + var kb=Math.max(0, Math.round(window.innerHeight - vv.height - vv.offsetTop)); + r.style.setProperty('--kb', kb+'px'); + var open=kb>4; document.body.classList.toggle('kb-open', open); + if(open){ var b=document.getElementById('msgs'); if(b) b.scrollTop=b.scrollHeight; } + }; + vv.addEventListener('resize', onVV); vv.addEventListener('scroll', onVV); } }catch(_){} })();