Support vertical scrolling in horizontal lists (#1161)
This commit is contained in:
parent
66d7cfe71b
commit
e0017543c1
@ -56,7 +56,7 @@ const RecentContacts: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||
});
|
||||
}, [loadTopUsers, loadContactList]);
|
||||
|
||||
useHorizontalScroll(topUsersRef, !topUserIds);
|
||||
useHorizontalScroll(topUsersRef.current, !topUserIds);
|
||||
|
||||
const handleClick = useCallback(
|
||||
(id: number) => {
|
||||
|
||||
@ -99,7 +99,7 @@ const EmojiPicker: FC<OwnProps & StateProps> = ({
|
||||
setActiveCategoryIndex(intersectingWithIndexes[Math.floor(intersectingWithIndexes.length / 2)].index);
|
||||
});
|
||||
|
||||
useHorizontalScroll(headerRef, !IS_MOBILE_SCREEN);
|
||||
useHorizontalScroll(headerRef.current, !IS_MOBILE_SCREEN);
|
||||
|
||||
// Scroll header when active set updates
|
||||
useEffect(() => {
|
||||
|
||||
@ -147,7 +147,7 @@ const StickerPicker: FC<OwnProps & StateProps & DispatchProps> = ({
|
||||
}
|
||||
}, [addedSetIds, loadAddedStickers]);
|
||||
|
||||
useHorizontalScroll(headerRef);
|
||||
useHorizontalScroll(headerRef.current);
|
||||
|
||||
// Scroll container and header when active set changes
|
||||
useEffect(() => {
|
||||
|
||||
@ -33,7 +33,7 @@ const TabList: FC<OwnProps> = ({
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const previousActiveTab = usePrevious(activeTab);
|
||||
|
||||
useHorizontalScroll(containerRef);
|
||||
useHorizontalScroll(containerRef.current);
|
||||
|
||||
// Scroll container to place active tab in the center
|
||||
useEffect(() => {
|
||||
|
||||
@ -1,9 +1,7 @@
|
||||
import { RefObject } from 'react';
|
||||
import { useEffect } from '../lib/teact/teact';
|
||||
|
||||
export default (containerRef: RefObject<HTMLElement>, isDisabled?: boolean) => {
|
||||
export default (container: HTMLElement | null, isDisabled?: boolean) => {
|
||||
useEffect(() => {
|
||||
const container = containerRef.current;
|
||||
if (!container) {
|
||||
return undefined;
|
||||
}
|
||||
@ -20,5 +18,5 @@ export default (containerRef: RefObject<HTMLElement>, isDisabled?: boolean) => {
|
||||
return () => {
|
||||
container.removeEventListener('wheel', handleScroll);
|
||||
};
|
||||
}, [containerRef, isDisabled]);
|
||||
}, [container, isDisabled]);
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user