добавлен адаптив для iphone

This commit is contained in:
DmitriyB
2022-08-10 14:59:25 +05:00
parent 7a771bd3e6
commit d5dd17cf91
2 changed files with 15 additions and 21 deletions
+14 -20
View File
@@ -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}>
+1 -1
View File
@@ -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}