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
|
|
@ -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;}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue