Fill the screen as an iPhone home-screen app (1.18.3)
This commit is contained in:
parent
6b5fe3f14c
commit
a46c9f9694
5 changed files with 50 additions and 4 deletions
|
|
@ -6,6 +6,11 @@ All notable changes to this project are documented here. The project follows
|
|||
|
||||
## [Unreleased]
|
||||
|
||||
## [1.18.3] — 2026-10-25
|
||||
|
||||
- Installed on an iPhone home screen, the game now fills the whole screen. Before,
|
||||
the tab bar floated above an empty strip at the bottom.
|
||||
|
||||
## [1.18.2] — 2026-10-25
|
||||
|
||||
- A new legendary badge, A Petabit a Second, for serving a full petabit per
|
||||
|
|
|
|||
4
package-lock.json
generated
4
package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "seriesoftubes",
|
||||
"version": "1.18.2",
|
||||
"version": "1.18.3",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "seriesoftubes",
|
||||
"version": "1.18.2",
|
||||
"version": "1.18.3",
|
||||
"devDependencies": {
|
||||
"jsdom": "24.1.3"
|
||||
},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "seriesoftubes",
|
||||
"version": "1.18.2",
|
||||
"version": "1.18.3",
|
||||
"description": "A cartoon browser game about building the internet.",
|
||||
"private": true,
|
||||
"license": "MIT",
|
||||
|
|
|
|||
|
|
@ -373,6 +373,10 @@ input.t{width:100%;box-sizing:border-box;border:3px solid var(--ink);border-radi
|
|||
A decluttered, app-like layout: a one-row status strip at the top, a tab bar at the bottom
|
||||
(play, speed, goals, deals, NOC, networks), and bottom sheets you drag up, down or away. */
|
||||
html,body{overscroll-behavior:none}
|
||||
/* iPhone home-screen app with a viewport shorter than the screen: the page box takes the real screen height
|
||||
and becomes the containing block for everything fixed, so bottom-anchored UI reaches the bottom. */
|
||||
html.iosfix,html.iosfix body{height:var(--app-h)}
|
||||
html.iosfix body{position:fixed;top:0;left:0;right:0;transform:translateZ(0)}
|
||||
button,.chip,.b,a{touch-action:manipulation;-webkit-tap-highlight-color:transparent}
|
||||
#hud,#tabbar,.tabs,.grab{-webkit-user-select:none;user-select:none;-webkit-touch-callout:none}
|
||||
#tabbar,.grab{display:none}
|
||||
|
|
@ -3207,8 +3211,18 @@ function openVxcModal({from,to,prov}){
|
|||
const cv=$('map'),ctx=cv.getContext('2d');
|
||||
const cam={x:1050,y:330,z:0.8};
|
||||
let CW=0,CH=0,DPR=1;
|
||||
function resize(){DPR=Math.min(2,window.devicePixelRatio||1);CW=innerWidth;CH=innerHeight;cv.width=CW*DPR;cv.height=CH*DPR;}
|
||||
/* 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. */
|
||||
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;
|
||||
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();
|
||||
// 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;};}
|
||||
function inPoly(x,y,pts){let ins=false;for(let i=0,j=pts.length-1;i<pts.length;j=i++){const [xi,yi]=pts[i],[xj,yj]=pts[j];if(((yi>y)!==(yj>y))&&(x<(xj-xi)*(y-yi)/(yj-yi)+xi))ins=!ins;}return ins;}
|
||||
function smoothPath(pts){const p=new Path2D();const n=pts.length;const mid=(a,b)=>[(a[0]+b[0])/2,(a[1]+b[1])/2];let m=mid(pts[n-1],pts[0]);p.moveTo(m[0],m[1]);for(let i=0;i<n;i++){const nx=pts[(i+1)%n];m=mid(pts[i],nx);p.quadraticCurveTo(pts[i][0],pts[i][1],m[0],m[1]);}p.closePath();return p;}
|
||||
|
|
|
|||
|
|
@ -185,3 +185,30 @@ test('#27 new networks get a random name, and "Another one" never repeats it', (
|
|||
assert.equal(ev("S.name"), 'My Own Net');
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
||||
test('iPhone home-screen app fills the screen when iOS reports a short viewport', () => {
|
||||
const { ev, dom, errors } = load();
|
||||
const w = dom.window;
|
||||
const set = (o, k, v) => Object.defineProperty(o, k, { value: v, configurable: true });
|
||||
set(w.navigator, 'userAgent', 'Mozilla/5.0 (iPhone; CPU iPhone OS 18_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148');
|
||||
set(w.navigator, 'standalone', true);
|
||||
set(w, 'screen', { width: 390, height: 844 });
|
||||
set(w, 'innerWidth', 390); set(w, 'innerHeight', 797); // one status bar short
|
||||
ev('resize()');
|
||||
assert.equal(ev("document.documentElement.classList.contains('iosfix')"), true);
|
||||
assert.equal(ev("document.documentElement.style.getPropertyValue('--app-h')"), '844px');
|
||||
assert.equal(ev('CH'), 844, 'the map is drawn to the real bottom');
|
||||
// landscape: the short side of the screen
|
||||
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
|
||||
set(w, 'innerWidth', 390); set(w, 'innerHeight', 844);
|
||||
ev('resize()');
|
||||
assert.equal(ev("document.documentElement.classList.contains('iosfix')"), false);
|
||||
set(w.navigator, 'standalone', false); set(w, 'innerHeight', 700);
|
||||
ev('resize()');
|
||||
assert.equal(ev("document.documentElement.classList.contains('iosfix')"), false);
|
||||
assert.equal(ev('CH'), 700);
|
||||
assert.deepEqual(errors, []);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue