Skip to content

Commit

Permalink
added optional param for using CameraStream
Browse files Browse the repository at this point in the history
  • Loading branch information
DimaDemchenko committed Jan 17, 2024
1 parent a142112 commit 640d2ab
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/components/demo-scroll/DemoScroll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,9 @@ export const DemoScroll = () => {
<InfiniteScroll<Pokemon>
getDataFunc={getDataFunc}
renderItem={renderItem}
maxItemsInList={230}
maxItemsInList={500}
itemsPerPage={5}
isScrollByCameraOn={true}
/>
</div>
)
Expand Down
4 changes: 3 additions & 1 deletion src/components/infinite-scroll/InfiniteScroll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ type InfiniteScrollProps<T> = {
renderItem: (item: T) => JSX.Element
maxItemsInList: number
itemsPerPage: number
isScrollByCameraOn?: boolean
}

export const InfiniteScroll = <T,>({
getDataFunc,
renderItem,
maxItemsInList,
itemsPerPage,
isScrollByCameraOn,
}: InfiniteScrollProps<T>) => {
const [items, setItems] = useState<T[]>([])
const [page, setPage] = useState(0)
Expand Down Expand Up @@ -71,7 +73,7 @@ export const InfiniteScroll = <T,>({

return (
<>
<CameraStream />
{isScrollByCameraOn && <CameraStream />}
<div className={styles.listContainer}>
<ul className={styles.list}>
{items.map((item, index) => (
Expand Down

0 comments on commit 640d2ab

Please sign in to comment.