добавлен адаптив для iphone
This commit is contained in:
+14
-20
@@ -4,33 +4,27 @@ import { ContextWindowHeight } from './components/contextWindowHeight';
|
||||
import { MainScreen } from './components/mainScreen/mainScreen';
|
||||
|
||||
function App() {
|
||||
const [windowHeight, setWindowHeight] = useState<number>(window.screen.availHeight);
|
||||
// const [windowHeight, setWindowHeight] = useState<number>(window.screen.availHeight);
|
||||
const [windowHeight, setWindowHeight] = useState<number>(window.visualViewport.height);
|
||||
|
||||
window.addEventListener('resize', e => {
|
||||
// window.addEventListener('resize', e => {
|
||||
// //@ts-ignore
|
||||
// setWindowHeight(e.currentTarget.screen.availHeight)
|
||||
// })
|
||||
|
||||
window.visualViewport.addEventListener('resize', (e) => {
|
||||
//@ts-ignore
|
||||
setWindowHeight(e.currentTarget.screen.availHeight)
|
||||
setWindowHeight(e.currentTarget.height, windowHeight)
|
||||
})
|
||||
|
||||
window.onload = function () {
|
||||
hideAddressBar();
|
||||
window.addEventListener("orientationchange", function () {
|
||||
hideAddressBar();
|
||||
}, false);
|
||||
}
|
||||
|
||||
function hideAddressBar() {
|
||||
setTimeout(function () {
|
||||
document.body.style.height = window.outerHeight + 'px';
|
||||
setTimeout(function () {
|
||||
window.scrollTo(0, 1);
|
||||
}, 1100);
|
||||
}, 1000);
|
||||
return false;
|
||||
}
|
||||
useEffect(() => {
|
||||
// alert(navigator.userAgent.includes('iPhone'))
|
||||
// alert(window.visualViewport.height + '\n' + windowHeight)
|
||||
}, [])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return (
|
||||
<div className="App">
|
||||
<ContextWindowHeight.Provider value={windowHeight}>
|
||||
|
||||
@@ -36,7 +36,7 @@ export const MainScreen:React.FC = React.memo(() => {
|
||||
/>
|
||||
</CSSTransition>
|
||||
{
|
||||
windowHeight < 700 ?
|
||||
windowHeight < 700 || navigator.userAgent.includes('iPhone') ?
|
||||
<CSSTransition
|
||||
in={showMobileUsersPart}
|
||||
timeout={300}
|
||||
|
||||
Reference in New Issue
Block a user