diff --git a/src/App.tsx b/src/App.tsx index 3aeeb8c..3c33b07 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -9,22 +9,19 @@ function App() { const [currentOrientaton, setCurrentOrientaton] = useState(window.orientation); - window.visualViewport.addEventListener('resize', (e) => { + window.visualViewport.onresize = (e) => { //@ts-ignore - setWindowHeight(e.currentTarget.height) - }) - + setWindowHeight(e.currentTarget.height); + } // !!! работает на свойстве помеченном как deprecate - на айфоне иначе хз как - // + спамит большим кол-вом ивентов, из за чего если оч много раз поворачиват телефон, веб упадет - window.addEventListener('orientationchange', e => { - //@ts-ignore - let angle = e.target.orientation as number; - if(currentOrientaton !== angle) { + window.onorientationchange = e => { + //@ts-ignore + let angle = e.target.orientation; + if(currentOrientaton !== angle) { setCurrentOrientaton(angle); } - return - }) + } useEffect(() => { if(!navigator.userAgent.includes('iPhone')) {