From 9de06f856a6a399259e666e0dd5831a81aa3bd1a Mon Sep 17 00:00:00 2001 From: Alexander Zinchuk Date: Mon, 17 May 2021 19:42:51 +0300 Subject: [PATCH] Revert refresh on resize --- src/util/windowSize.ts | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/src/util/windowSize.ts b/src/util/windowSize.ts index c1e57ca7e..fd8de5a9c 100644 --- a/src/util/windowSize.ts +++ b/src/util/windowSize.ts @@ -1,31 +1,12 @@ import { throttle } from './schedulers'; -import { - MOBILE_SCREEN_LANDSCAPE_MAX_HEIGHT, - MOBILE_SCREEN_LANDSCAPE_MAX_WIDTH, - MOBILE_SCREEN_MAX_WIDTH, -} from '../config'; -import { IS_MOBILE_SCREEN } from './environment'; type IDimensions = { width: number; height: number; }; -const IS_LANDSCAPE = IS_MOBILE_SCREEN && isLandscape(); - let windowSize = updateSizes(); -const handleResize = throttle(() => { - windowSize = updateSizes(); - - if ((isMobileScreen() !== IS_MOBILE_SCREEN) || (IS_MOBILE_SCREEN && IS_LANDSCAPE !== isLandscape())) { - window.location.reload(); - } -}, 250, true); - -window.addEventListener('resize', handleResize); -window.addEventListener('orientationchange', handleResize); - export function updateSizes(): IDimensions { const vh = window.innerHeight * 0.01; @@ -37,15 +18,12 @@ export function updateSizes(): IDimensions { }; } -function isMobileScreen() { - return windowSize.width <= MOBILE_SCREEN_MAX_WIDTH || ( - windowSize.width <= MOBILE_SCREEN_LANDSCAPE_MAX_WIDTH && windowSize.height <= MOBILE_SCREEN_LANDSCAPE_MAX_HEIGHT - ); -} +const handleResize = throttle(() => { + windowSize = updateSizes(); +}, 250, true); -function isLandscape() { - return window.matchMedia('(orientation: landscape)').matches; -} +window.addEventListener('resize', handleResize); +window.addEventListener('orientationchange', handleResize); export default { get: () => windowSize,