Forum Panel: Support swipe-to-close
This commit is contained in:
parent
fd0b27799c
commit
1fc8200e08
@ -132,11 +132,11 @@ const ChatFolders: FC<OwnProps & StateProps> = ({
|
|||||||
}, [activeChatFolder, folderTabs, setActiveChatFolder]);
|
}, [activeChatFolder, folderTabs, setActiveChatFolder]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!transitionRef.current || !IS_TOUCH_ENV || !folderTabs || !folderTabs.length) {
|
if (!IS_TOUCH_ENV || !folderTabs?.length || isForumPanelOpen) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return captureEvents(transitionRef.current, {
|
return captureEvents(transitionRef.current!, {
|
||||||
selectorToPreventScroll: '.chat-list',
|
selectorToPreventScroll: '.chat-list',
|
||||||
onSwipe: ((e, direction) => {
|
onSwipe: ((e, direction) => {
|
||||||
if (direction === SwipeDirection.Left) {
|
if (direction === SwipeDirection.Left) {
|
||||||
@ -150,7 +150,7 @@ const ChatFolders: FC<OwnProps & StateProps> = ({
|
|||||||
return false;
|
return false;
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
}, [activeChatFolder, folderTabs, setActiveChatFolder]);
|
}, [activeChatFolder, folderTabs, isForumPanelOpen, setActiveChatFolder]);
|
||||||
|
|
||||||
const isNotInFirstFolderRef = useRef();
|
const isNotInFirstFolderRef = useRef();
|
||||||
isNotInFirstFolderRef.current = !isInFirstFolder;
|
isNotInFirstFolderRef.current = !isInFirstFolder;
|
||||||
|
|||||||
@ -11,11 +11,13 @@ import {
|
|||||||
GENERAL_TOPIC_ID,
|
GENERAL_TOPIC_ID,
|
||||||
TOPICS_SLICE, TOPIC_HEIGHT_PX, TOPIC_LIST_SENSITIVE_AREA,
|
TOPICS_SLICE, TOPIC_HEIGHT_PX, TOPIC_LIST_SENSITIVE_AREA,
|
||||||
} from '../../../config';
|
} from '../../../config';
|
||||||
|
import { IS_TOUCH_ENV } from '../../../util/environment';
|
||||||
import { selectChat, selectCurrentMessageList, selectIsForumPanelOpen } from '../../../global/selectors';
|
import { selectChat, selectCurrentMessageList, selectIsForumPanelOpen } from '../../../global/selectors';
|
||||||
import buildClassName from '../../../util/buildClassName';
|
import buildClassName from '../../../util/buildClassName';
|
||||||
import { getOrderedTopics } from '../../../global/helpers';
|
import { getOrderedTopics } from '../../../global/helpers';
|
||||||
import captureEscKeyListener from '../../../util/captureEscKeyListener';
|
import captureEscKeyListener from '../../../util/captureEscKeyListener';
|
||||||
import { waitForTransitionEnd } from '../../../util/cssAnimationEndListeners';
|
import { waitForTransitionEnd } from '../../../util/cssAnimationEndListeners';
|
||||||
|
import { captureEvents, SwipeDirection } from '../../../util/captureEvents';
|
||||||
|
|
||||||
import useInfiniteScroll from '../../../hooks/useInfiniteScroll';
|
import useInfiniteScroll from '../../../hooks/useInfiniteScroll';
|
||||||
import { useIntersectionObserver, useOnIntersect } from '../../../hooks/useIntersectionObserver';
|
import { useIntersectionObserver, useOnIntersect } from '../../../hooks/useIntersectionObserver';
|
||||||
@ -144,6 +146,24 @@ const ForumPanel: FC<OwnProps & StateProps> = ({
|
|||||||
}
|
}
|
||||||
}, [isVisible, prevIsVisible]);
|
}, [isVisible, prevIsVisible]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!IS_TOUCH_ENV) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return captureEvents(ref.current!, {
|
||||||
|
selectorToPreventScroll: '.chat-list',
|
||||||
|
onSwipe: ((e, direction) => {
|
||||||
|
if (direction === SwipeDirection.Right) {
|
||||||
|
closeForumPanel();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
}, [closeForumPanel]);
|
||||||
|
|
||||||
function renderTopics() {
|
function renderTopics() {
|
||||||
const viewportOffset = orderedIds!.indexOf(viewportIds![0]);
|
const viewportOffset = orderedIds!.indexOf(viewportIds![0]);
|
||||||
|
|
||||||
@ -165,12 +185,12 @@ const ForumPanel: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
|
ref={ref}
|
||||||
className={buildClassName(
|
className={buildClassName(
|
||||||
styles.root,
|
styles.root,
|
||||||
isScrolled && styles.scrolled,
|
isScrolled && styles.scrolled,
|
||||||
lang.isRtl && styles.rtl,
|
lang.isRtl && styles.rtl,
|
||||||
)}
|
)}
|
||||||
ref={ref}
|
|
||||||
onTransitionEnd={!isOpen ? onCloseAnimationEnd : undefined}
|
onTransitionEnd={!isOpen ? onCloseAnimationEnd : undefined}
|
||||||
>
|
>
|
||||||
<div className="left-header">
|
<div className="left-header">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user