Skip to content

Commit f2ee945

Browse files
committed
Take delay as input
1 parent a7c48a0 commit f2ee945

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

packages/ui-components/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Changelog
22

3+
## [unreleased] - 2025-06-30
4+
5+
Updated infinite scorlling to take `delay` as input param
6+
37
## [4.3.0] - 2025-06-25
48

59
Updated infinite scrolling

packages/ui-components/src/infinite-scroll.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ interface InfiniteScrollProps<T> extends Omit<APIResultProps<T>, "params"> {
4141
resultsComponent?: React.ComponentType<{ data: T[] }>;
4242
perPage?: number;
4343
startPage?: number;
44-
initialData?: T[]; // to allow for server-side rendering for initial state
44+
initialData?: T[];
45+
delay?: number;
4546
}
4647

4748
type UpdateState<T> = { type: "update-state"; spec: Spec<ScrollState<T>> };
@@ -88,11 +89,12 @@ export function InfiniteScroll(props) {
8889
loadMore,
8990
offset = 0,
9091
isLoading,
92+
delay = 100,
9193
} = props;
9294
const { ref, inView } = useInView({
9395
rootMargin: `0px 0px ${offset}px 0px`,
9496
trackVisibility: true,
95-
delay: 100,
97+
delay: delay >= 100 ? delay : 100,
9698
});
9799

98100
const shouldLoadMore = hasMore && inView;
@@ -189,6 +191,7 @@ function InfiniteScrollView<T>(props: InfiniteScrollProps<T>) {
189191
perPage = 10,
190192
startPage = 0,
191193
initialItems = [],
194+
delay,
192195
} = props;
193196
const { get } = useAPIActions();
194197
const { getCount, getNextParams, getItems, hasMore } = props;
@@ -297,6 +300,7 @@ function InfiniteScrollView<T>(props: InfiniteScrollProps<T>) {
297300
loader: placeholder,
298301
useWindow: true,
299302
className,
303+
delay
300304
},
301305
[
302306
h.if(isEmpty)(emptyPlaceholder),

0 commit comments

Comments
 (0)