Fix iOS / iPadOS layouts w/ a funky JS+CSS trick
This commit is contained in:
parent
28853b2da6
commit
e3856c0984
4 changed files with 21 additions and 36 deletions
|
|
@ -51,16 +51,15 @@
|
||||||
<title>OpenSCAD Playground</title>
|
<title>OpenSCAD Playground</title>
|
||||||
<style>
|
<style>
|
||||||
#root,
|
#root,
|
||||||
body {
|
body,
|
||||||
|
html {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
flex: 1;
|
flex: 1;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
position: fixed;
|
|
||||||
top: 0;
|
height: 100vh;
|
||||||
bottom: 0;
|
height: var(--app-height);
|
||||||
left: 0;
|
|
||||||
right: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.p-tabmenu-nav {
|
.p-tabmenu-nav {
|
||||||
|
|
|
||||||
|
|
@ -54,28 +54,13 @@ export function App({initialState, fs}: {initialState: State, fs: FS}) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: test this again:
|
|
||||||
// body {
|
|
||||||
// min-height: 100vh;
|
|
||||||
// min-height: fill-available;
|
|
||||||
// min-height: -webkit-fill-available;
|
|
||||||
// }
|
|
||||||
// html {
|
|
||||||
// height: fill-available;
|
|
||||||
// height: -webkit-fill-available;
|
|
||||||
// }
|
|
||||||
const isIPhone = /iPhone/.test(navigator.userAgent)
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ModelContext.Provider value={model}>
|
<ModelContext.Provider value={model}>
|
||||||
<FSContext.Provider value={fs}>
|
<FSContext.Provider value={fs}>
|
||||||
<div className='flex flex-column' style={{
|
<div className='flex flex-column' style={{
|
||||||
// height: '100vh'
|
flex: 1,
|
||||||
// maxHeight: '-webkit-fill-available',
|
|
||||||
height: isIPhone ? "calc(100vh - 80px - env(safe-area-inset-bottom) - env(safe-area-inset-top))" : '100vh'
|
|
||||||
}}>
|
}}>
|
||||||
{isIPhone && <Footer />}
|
|
||||||
|
|
||||||
<PanelSwitcher />
|
<PanelSwitcher />
|
||||||
|
|
||||||
|
|
@ -84,7 +69,6 @@ export function App({initialState, fs}: {initialState: State, fs: FS}) {
|
||||||
flex: 1,
|
flex: 1,
|
||||||
position: 'relative'
|
position: 'relative'
|
||||||
}}>
|
}}>
|
||||||
{/* {position: 'relative'}}> */}
|
|
||||||
|
|
||||||
<EditorPanel className={`
|
<EditorPanel className={`
|
||||||
opacity-animated
|
opacity-animated
|
||||||
|
|
@ -95,19 +79,9 @@ export function App({initialState, fs}: {initialState: State, fs: FS}) {
|
||||||
{/* <CustomizerPanel className={`${getPanelClasses('customizer')} absolute-fill`} style={getPanelStyle('customizer')} /> */}
|
{/* <CustomizerPanel className={`${getPanelClasses('customizer')} absolute-fill`} style={getPanelStyle('customizer')} /> */}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!isIPhone && <Footer />}
|
<Footer />
|
||||||
</div>
|
</div>
|
||||||
</FSContext.Provider>
|
</FSContext.Provider>
|
||||||
</ModelContext.Provider>
|
</ModelContext.Provider>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// <Splitter style={{ flex: 1 }}>
|
|
||||||
// <SplitterPanel className="flex flex-column align-items-center justify-content-center">
|
|
||||||
// <EditorPanel />
|
|
||||||
// </SplitterPanel>
|
|
||||||
// <SplitterPanel className="flex flex-column align-items-center justify-content-center">
|
|
||||||
// <ViewerPanel/>
|
|
||||||
// </SplitterPanel>
|
|
||||||
// </Splitter>
|
|
||||||
// <Footer />
|
|
||||||
|
|
@ -11,6 +11,7 @@ import { createInitialState } from './state/initial-state';
|
||||||
import './index.css';
|
import './index.css';
|
||||||
|
|
||||||
import debug from 'debug';
|
import debug from 'debug';
|
||||||
|
import { registerCustomAppHeightCSSProperty } from './utils';
|
||||||
const log = debug('app:log');
|
const log = debug('app:log');
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'production') {
|
if (process.env.NODE_ENV !== 'production') {
|
||||||
|
|
@ -21,7 +22,8 @@ if (process.env.NODE_ENV !== 'production') {
|
||||||
}
|
}
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
|
registerCustomAppHeightCSSProperty();
|
||||||
|
|
||||||
const fs = await createEditorFS('/');
|
const fs = await createEditorFS('/');
|
||||||
await registerOpenSCADLanguage(fs, '/', zipArchives);
|
await registerOpenSCADLanguage(fs, '/', zipArchives);
|
||||||
|
|
||||||
|
|
|
||||||
10
src/utils.ts
10
src/utils.ts
|
|
@ -86,4 +86,14 @@ export function formatMillis(n: number) {
|
||||||
return `${Math.floor(n)}ms`;
|
return `${Math.floor(n)}ms`;
|
||||||
|
|
||||||
return `${Math.floor(n / 100) / 10}sec`;
|
return `${Math.floor(n / 100) / 10}sec`;
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://medium.com/quick-code/100vh-problem-with-ios-safari-92ab23c852a8
|
||||||
|
export function registerCustomAppHeightCSSProperty() {
|
||||||
|
const updateAppHeight = () => {
|
||||||
|
const doc = document.documentElement
|
||||||
|
doc.style.setProperty('--app-height', `${window.innerHeight}px`)
|
||||||
|
}
|
||||||
|
window.addEventListener('resize', updateAppHeight)
|
||||||
|
updateAppHeight();
|
||||||
}
|
}
|
||||||
Loading…
Reference in a new issue