diff --git a/CHANGELOG.md b/CHANGELOG.md index 95c4861..d2aec47 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,11 @@ All notable changes to this project are documented here. The project follows ## [Unreleased] +## [1.18.4] — 2026-10-25 + +- The iPhone home-screen fix from 1.18.3 now stays in place. Before, it worked + at launch and then the empty strip under the tab bar came back. + ## [1.18.3] — 2026-10-25 - Installed on an iPhone home screen, the game now fills the whole screen. Before, diff --git a/package-lock.json b/package-lock.json index dcacdf9..07348b1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "seriesoftubes", - "version": "1.18.3", + "version": "1.18.4", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "seriesoftubes", - "version": "1.18.3", + "version": "1.18.4", "devDependencies": { "jsdom": "24.1.3" }, diff --git a/package.json b/package.json index 127ae9f..d7c5ee6 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "seriesoftubes", - "version": "1.18.3", + "version": "1.18.4", "description": "A cartoon browser game about building the internet.", "private": true, "license": "MIT", diff --git a/site/index.html b/site/index.html index 60c1eab..4f4a05f 100644 --- a/site/index.html +++ b/site/index.html @@ -3213,14 +3213,25 @@ const cam={x:1050,y:330,z:0.8}; let CW=0,CH=0,DPR=1; /* Installed on an iPhone home screen with a translucent status bar, iOS can report a viewport one status bar shorter than the screen while drawing from the very top, leaving an empty strip under the tab bar. - Measure the screen instead; only on iPhone, standalone, and only when the gap is about a status bar. */ + Measure the screen instead, on standalone iPhones only. It must not depend on the gap it fixes: once + the page is sized to the screen, iOS reports a full viewport, and switching back would bring the strip back. */ function fixStandaloneHeight(){const R0=document.documentElement; const sa=window.navigator.standalone===true||!!(window.matchMedia&&matchMedia('(display-mode: standalone)').matches); const sh=screen&&screen.width&&screen.height?(innerWidth>innerHeight?Math.min(screen.width,screen.height):Math.max(screen.width,screen.height)):0,gap=sh-innerHeight; - const on=sa&&/iPhone|iPod/.test(navigator.userAgent)&&gap>1&&gap<=80; + const on=sa&&/iPhone|iPod/.test(navigator.userAgent)&&sh>0&&gap>=0&&gap<=80; R0.classList.toggle('iosfix',on);if(on)R0.style.setProperty('--app-h',sh+'px');else R0.style.removeProperty('--app-h');return on?sh:0;} function resize(){const ah=fixStandaloneHeight();DPR=Math.min(2,window.devicePixelRatio||1);CW=innerWidth;CH=ah||innerHeight;cv.width=CW*DPR;cv.height=CH*DPR;} addEventListener('resize',()=>{resize();WL.key=null;renderLeft();fitHud();});resize(); +// Viewport readout for debugging phone layouts: open the game once with ?vp in the address (or the start URL). +function vpDebug(){let el=document.getElementById('vpdbg');if(!el){el=document.createElement('pre');el.id='vpdbg';el.style.cssText='position:fixed;left:8px;bottom:calc(var(--tabbar,0px) + 8px);z-index:99;margin:0;padding:6px 8px;background:rgba(30,38,64,.85);color:#7CFFB2;font:11px/1.35 ui-monospace,monospace;border-radius:8px;pointer-events:none';document.body.appendChild(el); + const pr=document.createElement('div');pr.id='vpprobe';pr.style.cssText='position:fixed;visibility:hidden;padding:env(safe-area-inset-top,0px) 0 env(safe-area-inset-bottom,0px)';document.body.appendChild(pr);} + const pr=document.getElementById('vpprobe'),cs=getComputedStyle(pr),vv=window.visualViewport,de=document.documentElement,tb=document.getElementById('tabbar').getBoundingClientRect(); + el.textContent=`inner ${innerWidth}×${innerHeight} · screen ${screen.width}×${screen.height}\nvv ${vv?Math.round(vv.width)+'×'+Math.round(vv.height)+' top '+Math.round(vv.offsetTop):'-'} · client ${de.clientHeight}\nsafe top ${cs.paddingTop} bottom ${cs.paddingBottom}\nstandalone ${navigator.standalone===true||!!(window.matchMedia&&matchMedia('(display-mode: standalone)').matches)} · iosfix ${de.classList.contains('iosfix')} · CH ${CH}\nbody ${Math.round(document.body.getBoundingClientRect().height)} · tabbar ${Math.round(tb.top)}–${Math.round(tb.bottom)}`;} +let VP_T=null;const vpOn=on=>{clearInterval(VP_T);VP_T=null;const el=document.getElementById('vpdbg');if(el)el.remove();if(on){VP_T=setInterval(vpDebug,500);vpDebug();}try{on?localStorage.setItem('sot-vp','1'):localStorage.removeItem('sot-vp');}catch(e){}}; +if(/[?&]vp\b/.test(location.search))vpOn(true);else if(/[?&]novp\b/.test(location.search))vpOn(false); +try{if(localStorage.getItem('sot-vp')==='1')vpOn(true);}catch(e){} +// Inside an installed app there is no address bar: five quick taps on the date toggle the readout. +{let taps=[];document.getElementById('hDate').closest('.chip,div').addEventListener('click',()=>{const t=performance.now();taps=taps.filter(x=>t-x<1500).concat(t);if(taps.length>=5){taps=[];vpOn(!VP_T);}});} // iOS settles the standalone viewport a moment after launch and after rotating. for(const t of [300,1000])setTimeout(()=>{resize();WL.key=null;},t);addEventListener('pageshow',()=>{resize();WL.key=null;}); function rng(seed){return()=>{seed|=0;seed=seed+0x6D2B79F5|0;let t=Math.imul(seed^seed>>>15,1|seed);t=t+Math.imul(t^t>>>7,61|t)^t;return((t^t>>>14)>>>0)/4294967296;};} diff --git a/tests/modes.test.js b/tests/modes.test.js index 13b935a..3c28333 100644 --- a/tests/modes.test.js +++ b/tests/modes.test.js @@ -202,10 +202,12 @@ test('iPhone home-screen app fills the screen when iOS reports a short viewport' set(w, 'innerWidth', 844); set(w, 'innerHeight', 370); ev('resize()'); assert.equal(ev('CH'), 390); - // a correct viewport, or Safari in a tab, leaves the page alone + // once fixed, iOS reports a full viewport: the fix must stay on, or the strip comes back set(w, 'innerWidth', 390); set(w, 'innerHeight', 844); ev('resize()'); - assert.equal(ev("document.documentElement.classList.contains('iosfix')"), false); + assert.equal(ev("document.documentElement.classList.contains('iosfix')"), true); + assert.equal(ev('CH'), 844); + // Safari in a tab leaves the page alone set(w.navigator, 'standalone', false); set(w, 'innerHeight', 700); ev('resize()'); assert.equal(ev("document.documentElement.classList.contains('iosfix')"), false);