From 5d684249a0e7bd60195118925ecbc3103f265875 Mon Sep 17 00:00:00 2001 From: Victoria Zhizhonkova Date: Fri, 23 Sep 2022 17:16:18 +0700 Subject: [PATCH] =?UTF-8?q?fix(ModalRoot):=20=D0=98=D1=81=D0=BF=D1=80?= =?UTF-8?q?=D0=B0=D0=B2=D0=BB=D1=8F=D0=B5=D1=82=20=D1=81=D0=BA=D1=80=D0=BE?= =?UTF-8?q?=D0=BB=D0=BB=20=D0=BF=D1=80=D0=B8=20touch-=D1=81=D0=BE=D0=B1?= =?UTF-8?q?=D1=8B=D1=82=D0=B8=D1=8F=D1=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ModalRoot/ModalRoot.tsx | 41 -------------------------- 1 file changed, 41 deletions(-) diff --git a/src/components/ModalRoot/ModalRoot.tsx b/src/components/ModalRoot/ModalRoot.tsx index faedf83267..706c2489e9 100644 --- a/src/components/ModalRoot/ModalRoot.tsx +++ b/src/components/ModalRoot/ModalRoot.tsx @@ -101,7 +101,6 @@ class ModalRootTouchComponent extends React.Component< this.frameIds = {}; } - private documentScrolling = false; private readonly maskElementRef: React.RefObject; private readonly viewportRef = React.createRef(); private maskAnimationFrame: number | undefined = undefined; @@ -144,7 +143,6 @@ class ModalRootTouchComponent extends React.Component< } componentWillUnmount() { - this.toggleDocumentScrolling(true); this.window!.removeEventListener( "resize", this.updateModalTranslate, @@ -196,47 +194,8 @@ class ModalRootTouchComponent extends React.Component< this.restoreFocusTo.focus(); this.restoreFocusTo = null; } - - this.toggleDocumentScrolling( - !this.props.activeModal && !this.props.exitingModal - ); - } - - /* Отключает скролл документа */ - toggleDocumentScrolling(enabled: boolean) { - if (this.documentScrolling === enabled) { - return; - } - this.documentScrolling = enabled; - - if (enabled) { - // Здесь нужен последний аргумент с такими же параметрами, потому что - // некоторые браузеры на странных вендорах типа Meizu не удаляют обработчик. - // https://github.com/VKCOM/VKUI/issues/444 - this.window!.removeEventListener("touchmove", this.preventTouch, { - // @ts-ignore (В интерфейсе EventListenerOptions нет поля passive) - passive: false, - }); - } else { - this.window!.addEventListener("touchmove", this.preventTouch, { - passive: false, - }); - } } - preventTouch = (event: any) => { - if (!event) { - return false; - } - while (event.originalEvent) { - event = event.originalEvent; - } - if (event.preventDefault) { - event.preventDefault(); - } - return false; - }; - updateModalTranslate = () => { const modalState = this.getModalState(this.props.activeModal); modalState && this.animateTranslate(modalState, modalState.translateY);