Skip to content

Commit

Permalink
move infinite scroll marker higher for feed layout
Browse files Browse the repository at this point in the history
  • Loading branch information
andreymikhadyuk committed Oct 30, 2023
1 parent 40f18ef commit 8808629
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
@import "../../../../styles/sizes";

.content {
position: relative;
flex: 1;
padding: 0 1.5rem;
display: flex;
Expand All @@ -17,6 +18,11 @@
justify-content: center;
}

.infiniteScrollMarker {
position: absolute;
bottom: 50rem;
}

.emptyText {
margin: 0;
font-weight: 500;
Expand Down
5 changes: 5 additions & 0 deletions src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -653,6 +653,11 @@ const FeedLayout: ForwardRefRenderFunction<FeedLayoutRef, FeedLayoutProps> = (
{topContent}
{isContentEmpty && <p className={styles.emptyText}>{emptyText}</p>}
<InfiniteScroll
markerClassName={
allFeedItems && allFeedItems.length > 7
? styles.infiniteScrollMarker
: ""
}
onFetchNext={onFetchNext}
isLoading={loading}
loaderDelay={LOADER_APPEARANCE_DELAY}
Expand Down
6 changes: 4 additions & 2 deletions src/shared/ui-kit/InfiniteScroll/InfiniteScroll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ import styles from "./InfiniteScroll.module.scss";
interface InfiniteScrollProps {
isLoading: boolean;
loaderDelay?: number;
markerClassName?: string;
onFetchNext: () => void;
}

const InfiniteScroll: FC<InfiniteScrollProps> = (props) => {
const { isLoading, loaderDelay, onFetchNext, children } = props;
const { isLoading, loaderDelay, markerClassName, onFetchNext, children } =
props;
const [isInnerLoading, setIsInnerLoading] = useState(isLoading);
const markerRef = useRef<HTMLDivElement>(null);
const isMarkerOnScreen = useIntersectionObserver(markerRef.current);
Expand Down Expand Up @@ -39,7 +41,7 @@ const InfiniteScroll: FC<InfiniteScrollProps> = (props) => {
return (
<>
{children}
<div ref={markerRef} />
<div className={markerClassName} ref={markerRef} />
{isLoading && (
<div className={styles.loaderWrapper}>
<Loader delay={loaderDelay} />
Expand Down

0 comments on commit 8808629

Please sign in to comment.