Reaction Selector: Fix broken scroll
This commit is contained in:
parent
6afb17978d
commit
7a75293a16
@ -1,5 +1,5 @@
|
|||||||
import React, {
|
import React, {
|
||||||
memo, useLayoutEffect, useMemo, useRef,
|
memo, useMemo, useRef,
|
||||||
} from '../../../lib/teact/teact';
|
} from '../../../lib/teact/teact';
|
||||||
|
|
||||||
import type { FC } from '../../../lib/teact/teact';
|
import type { FC } from '../../../lib/teact/teact';
|
||||||
@ -13,7 +13,6 @@ import { IS_COMPACT_MENU } from '../../../util/environment';
|
|||||||
import { isSameReaction, canSendReaction, getReactionUniqueKey } from '../../../global/helpers';
|
import { isSameReaction, canSendReaction, getReactionUniqueKey } from '../../../global/helpers';
|
||||||
|
|
||||||
import useHorizontalScroll from '../../../hooks/useHorizontalScroll';
|
import useHorizontalScroll from '../../../hooks/useHorizontalScroll';
|
||||||
import useFlag from '../../../hooks/useFlag';
|
|
||||||
|
|
||||||
import ReactionSelectorReaction from './ReactionSelectorReaction';
|
import ReactionSelectorReaction from './ReactionSelectorReaction';
|
||||||
|
|
||||||
@ -44,15 +43,9 @@ const ReactionSelector: FC<OwnProps> = ({
|
|||||||
}) => {
|
}) => {
|
||||||
// eslint-disable-next-line no-null/no-null
|
// eslint-disable-next-line no-null/no-null
|
||||||
const itemsScrollRef = useRef<HTMLDivElement>(null);
|
const itemsScrollRef = useRef<HTMLDivElement>(null);
|
||||||
const [isHorizontalScrollEnabled, enableHorizontalScroll] = useFlag(false);
|
useHorizontalScroll(itemsScrollRef);
|
||||||
useHorizontalScroll(itemsScrollRef, !isHorizontalScrollEnabled);
|
|
||||||
|
|
||||||
useLayoutEffect(() => {
|
|
||||||
enableHorizontalScroll();
|
|
||||||
}, [enableHorizontalScroll]);
|
|
||||||
|
|
||||||
const handleWheel = (e: React.WheelEvent | React.TouchEvent) => {
|
const handleWheel = (e: React.WheelEvent | React.TouchEvent) => {
|
||||||
if (!itemsScrollRef) return;
|
|
||||||
const deltaY = 'deltaY' in e ? e.deltaY : getTouchY(e);
|
const deltaY = 'deltaY' in e ? e.deltaY : getTouchY(e);
|
||||||
|
|
||||||
if (deltaY && e.cancelable) {
|
if (deltaY && e.cancelable) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user