Left Main: Hide tab shadow when no scroll (#6743)
This commit is contained in:
parent
c01f4264ab
commit
d94e492584
@ -22,6 +22,7 @@ import useFolderTabs from '../../../hooks/useFolderTabs';
|
|||||||
import useHistoryBack from '../../../hooks/useHistoryBack';
|
import useHistoryBack from '../../../hooks/useHistoryBack';
|
||||||
import useLang from '../../../hooks/useLang';
|
import useLang from '../../../hooks/useLang';
|
||||||
import useLastCallback from '../../../hooks/useLastCallback';
|
import useLastCallback from '../../../hooks/useLastCallback';
|
||||||
|
import useScrolledState from '../../../hooks/useScrolledState';
|
||||||
import useShowTransition from '../../../hooks/useShowTransition';
|
import useShowTransition from '../../../hooks/useShowTransition';
|
||||||
|
|
||||||
import StoryRibbon from '../../story/StoryRibbon';
|
import StoryRibbon from '../../story/StoryRibbon';
|
||||||
@ -86,10 +87,17 @@ const ChatFolders: FC<OwnProps & StateProps> = ({
|
|||||||
|
|
||||||
const lang = useLang();
|
const lang = useLang();
|
||||||
|
|
||||||
|
const { isAtBeginning: isNotScrolled, handleScroll, updateScrollState } = useScrolledState();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadChatFolders();
|
loadChatFolders();
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const activeList = transitionRef.current?.querySelector<HTMLElement>('.chat-list.Transition_slide-active');
|
||||||
|
updateScrollState(activeList ?? undefined);
|
||||||
|
}, [activeChatFolder, updateScrollState]);
|
||||||
|
|
||||||
const {
|
const {
|
||||||
ref,
|
ref,
|
||||||
shouldRender: shouldRenderStoryRibbon,
|
shouldRender: shouldRenderStoryRibbon,
|
||||||
@ -231,6 +239,7 @@ const ChatFolders: FC<OwnProps & StateProps> = ({
|
|||||||
isFoldersSidebarShown={isFoldersSidebarShown}
|
isFoldersSidebarShown={isFoldersSidebarShown}
|
||||||
isStoryRibbonShown={isStoryRibbonShown}
|
isStoryRibbonShown={isStoryRibbonShown}
|
||||||
withTags
|
withTags
|
||||||
|
onScroll={handleScroll}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -255,6 +264,7 @@ const ChatFolders: FC<OwnProps & StateProps> = ({
|
|||||||
tabs={folderTabs}
|
tabs={folderTabs}
|
||||||
activeTab={activeChatFolder}
|
activeTab={activeChatFolder}
|
||||||
onSwitchTab={handleSwitchTab}
|
onSwitchTab={handleSwitchTab}
|
||||||
|
className={!isNotScrolled ? 'scrolled' : undefined}
|
||||||
/>
|
/>
|
||||||
) : shouldRenderPlaceholder ? (
|
) : shouldRenderPlaceholder ? (
|
||||||
<div ref={placeholderRef} className="tabs-placeholder" />
|
<div ref={placeholderRef} className="tabs-placeholder" />
|
||||||
|
|||||||
@ -48,6 +48,7 @@ type OwnProps = {
|
|||||||
isFoldersSidebarShown?: boolean;
|
isFoldersSidebarShown?: boolean;
|
||||||
isStoryRibbonShown?: boolean;
|
isStoryRibbonShown?: boolean;
|
||||||
foldersDispatch?: FolderEditDispatch;
|
foldersDispatch?: FolderEditDispatch;
|
||||||
|
onScroll?: (e: React.UIEvent<HTMLDivElement>) => void;
|
||||||
};
|
};
|
||||||
|
|
||||||
const INTERSECTION_THROTTLE = 200;
|
const INTERSECTION_THROTTLE = 200;
|
||||||
@ -66,6 +67,7 @@ const ChatList = ({
|
|||||||
isFoldersSidebarShown,
|
isFoldersSidebarShown,
|
||||||
isStoryRibbonShown,
|
isStoryRibbonShown,
|
||||||
foldersDispatch,
|
foldersDispatch,
|
||||||
|
onScroll,
|
||||||
}: OwnProps) => {
|
}: OwnProps) => {
|
||||||
const {
|
const {
|
||||||
openChat,
|
openChat,
|
||||||
@ -227,6 +229,7 @@ const ChatList = ({
|
|||||||
withAbsolutePositioning
|
withAbsolutePositioning
|
||||||
maxHeight={chatsHeight + archiveHeight + panesHeight}
|
maxHeight={chatsHeight + archiveHeight + panesHeight}
|
||||||
onLoadMore={getMore}
|
onLoadMore={getMore}
|
||||||
|
onScroll={onScroll}
|
||||||
>
|
>
|
||||||
{isAllFolder && <ChatListPanes key="panes" onHeightChange={setPanesHeight} />}
|
{isAllFolder && <ChatListPanes key="panes" onHeightChange={setPanesHeight} />}
|
||||||
{shouldDisplayArchive && (
|
{shouldDisplayArchive && (
|
||||||
|
|||||||
@ -35,11 +35,17 @@
|
|||||||
|
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
|
|
||||||
border-bottom: 0;
|
border-bottom: 1px solid var(--color-borders);
|
||||||
|
|
||||||
opacity: 1;
|
opacity: 1;
|
||||||
|
box-shadow: none;
|
||||||
|
|
||||||
transition: opacity var(--layer-transition);
|
transition: opacity var(--layer-transition), box-shadow 0.2s, border-color 0.2s;
|
||||||
|
|
||||||
|
&.scrolled {
|
||||||
|
border-bottom-color: transparent;
|
||||||
|
box-shadow: 0 2px 2px var(--color-light-shadow);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
&--tabs-hidden .TabList {
|
&--tabs-hidden .TabList {
|
||||||
|
|||||||
@ -15,5 +15,17 @@ export default function useScrolledState(threshold = THRESHOLD) {
|
|||||||
setIsAtEnd(scrollHeight - scrollTop - clientHeight < threshold);
|
setIsAtEnd(scrollHeight - scrollTop - clientHeight < threshold);
|
||||||
});
|
});
|
||||||
|
|
||||||
return { isAtBeginning, isAtEnd, handleScroll };
|
const updateScrollState = useLastCallback((element: HTMLElement | undefined) => {
|
||||||
|
if (!element) {
|
||||||
|
setIsAtBeginning(true);
|
||||||
|
setIsAtEnd(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const { scrollHeight, scrollTop, clientHeight } = element;
|
||||||
|
setIsAtBeginning(scrollTop < threshold);
|
||||||
|
setIsAtEnd(scrollHeight - scrollTop - clientHeight < threshold);
|
||||||
|
});
|
||||||
|
|
||||||
|
return { isAtBeginning, isAtEnd, handleScroll, updateScrollState };
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user