[Refactoring] Simplify disableScrolling/enableScrolling
This commit is contained in:
parent
03de021b82
commit
a59a3a4217
@ -24,19 +24,21 @@ import {
|
|||||||
} from '../../global/helpers';
|
} from '../../global/helpers';
|
||||||
import {
|
import {
|
||||||
selectBot,
|
selectBot,
|
||||||
selectCanManage, selectCanTranslateChat,
|
selectCanManage,
|
||||||
|
selectCanTranslateChat,
|
||||||
selectChat,
|
selectChat,
|
||||||
selectChatFullInfo,
|
selectChatFullInfo,
|
||||||
selectCurrentMessageList,
|
selectCurrentMessageList,
|
||||||
selectIsChatWithSelf,
|
selectIsChatWithSelf,
|
||||||
selectIsPremiumPurchaseBlocked,
|
selectIsPremiumPurchaseBlocked,
|
||||||
selectIsRightColumnShown, selectNotifyExceptions,
|
selectIsRightColumnShown,
|
||||||
|
selectNotifyExceptions,
|
||||||
selectNotifySettings,
|
selectNotifySettings,
|
||||||
selectTabState,
|
selectTabState,
|
||||||
selectUser,
|
selectUser,
|
||||||
selectUserFullInfo,
|
selectUserFullInfo,
|
||||||
} from '../../global/selectors';
|
} from '../../global/selectors';
|
||||||
import { disableScrolling, enableScrolling } from '../../util/scrollLock';
|
import { disableScrolling } from '../../util/scrollLock';
|
||||||
|
|
||||||
import useAppLayout from '../../hooks/useAppLayout';
|
import useAppLayout from '../../hooks/useAppLayout';
|
||||||
import useFlag from '../../hooks/useFlag';
|
import useFlag from '../../hooks/useFlag';
|
||||||
@ -391,11 +393,7 @@ const HeaderMenuContainer: FC<OwnProps & StateProps> = ({
|
|||||||
closeMenu();
|
closeMenu();
|
||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(disableScrolling, []);
|
||||||
disableScrolling();
|
|
||||||
|
|
||||||
return enableScrolling;
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const lang = useOldLang();
|
const lang = useOldLang();
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@ import type { IAnchorPosition } from '../../../types';
|
|||||||
|
|
||||||
import { getUserFullName, isUserId } from '../../../global/helpers';
|
import { getUserFullName, isUserId } from '../../../global/helpers';
|
||||||
import buildClassName from '../../../util/buildClassName';
|
import buildClassName from '../../../util/buildClassName';
|
||||||
import { disableScrolling, enableScrolling } from '../../../util/scrollLock';
|
import { disableScrolling } from '../../../util/scrollLock';
|
||||||
import { REM } from '../../common/helpers/mediaDimensions';
|
import { REM } from '../../common/helpers/mediaDimensions';
|
||||||
import renderText from '../../common/helpers/renderText';
|
import renderText from '../../common/helpers/renderText';
|
||||||
import { getMessageCopyOptions } from './helpers/copyOptions';
|
import { getMessageCopyOptions } from './helpers/copyOptions';
|
||||||
@ -323,9 +323,7 @@ const MessageContextMenu: FC<OwnProps> = ({
|
|||||||
}, [isOpen, markIsReady, unmarkIsReady]);
|
}, [isOpen, markIsReady, unmarkIsReady]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
disableScrolling(scrollableRef.current, '.ReactionPicker');
|
return disableScrolling(scrollableRef.current, '.ReactionPicker');
|
||||||
|
|
||||||
return enableScrolling;
|
|
||||||
}, [isOpen]);
|
}, [isOpen]);
|
||||||
|
|
||||||
const handleOpenMessageReactionPicker = useLastCallback((position: IAnchorPosition) => {
|
const handleOpenMessageReactionPicker = useLastCallback((position: IAnchorPosition) => {
|
||||||
|
|||||||
@ -67,6 +67,8 @@ export function disableScrolling(el?: HTMLElement | null, _excludedClosestSelect
|
|||||||
document.addEventListener('wheel', preventDefault, { passive: false });
|
document.addEventListener('wheel', preventDefault, { passive: false });
|
||||||
document.addEventListener('touchmove', preventDefault, { passive: false });
|
document.addEventListener('touchmove', preventDefault, { passive: false });
|
||||||
document.onkeydown = preventDefaultForScrollKeys;
|
document.onkeydown = preventDefaultForScrollKeys;
|
||||||
|
|
||||||
|
return enableScrolling;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function enableScrolling() {
|
export function enableScrolling() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user