Skip to content

Commit

Permalink
fix: scroll area
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Mar 21, 2024
1 parent fdd40cd commit 8085e65
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions src/components/ui/scroll-area/ScrollArea.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,24 +61,12 @@ Scrollbar.displayName = 'ScrollArea.Scrollbar'

export const Viewport = React.forwardRef<
React.ElementRef<typeof ScrollAreaBase.Viewport>,
React.ComponentPropsWithoutRef<typeof ScrollAreaBase.Viewport> & {
onScrollToBottom?: () => void
}
>(({ className, onScrollToBottom, onScroll, ...rest }, forwardedRef) => (
React.ComponentPropsWithoutRef<typeof ScrollAreaBase.Viewport>
>(({ className, ...rest }, forwardedRef) => (
<ScrollAreaBase.Viewport
{...rest}
ref={forwardedRef}
asChild
className={clsxm('block h-full w-full', className)}
onScroll={(event) => {
const { clientHeight, scrollHeight, scrollTop } = event.target as Element

if (scrollHeight - scrollTop === clientHeight) {
onScrollToBottom?.()
}

onScroll?.(event)
}}
/>
))
Viewport.displayName = 'ScrollArea.Viewport'
Expand Down

0 comments on commit 8085e65

Please sign in to comment.