Skip to content

Commit 829148f

Browse files
committed
feat: expose scrollElement into sheetRef
1 parent 001158d commit 829148f

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/BottomSheet.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,12 +415,14 @@ export const BottomSheet = React.forwardRef<
415415
send('CLOSE')
416416
}
417417
}, [_open, send, ready])
418+
418419
useLayoutEffect(() => {
419420
// Adjust the height whenever the snap points are changed due to resize events
420421
if (maxHeight || maxSnap || minSnap) {
421422
send('RESIZE')
422423
}
423424
}, [maxHeight, maxSnap, minSnap, send])
425+
424426
useEffect(
425427
() => () => {
426428
// Ensure effects are cleaned up on unmount, in case they're not cleaned up otherwise
@@ -446,6 +448,9 @@ export const BottomSheet = React.forwardRef<
446448
get height() {
447449
return heightRef.current
448450
},
451+
get scrollElement() {
452+
return scrollRef.current
453+
},
449454
}),
450455
[send]
451456
)
@@ -670,6 +675,7 @@ export const BottomSheet = React.forwardRef<
670675
</div>
671676
)}
672677
<div
678+
id="scroll"
673679
key="scroll"
674680
data-rsbs-scroll
675681
ref={scrollRef}

src/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,4 +176,6 @@ export interface RefHandles {
176176
* It's update lifecycle with events are onSpringStart and onSpringCancel will give you the old value, while onSpringEnd will give you the current one.
177177
*/
178178
height: number
179+
180+
scrollElement: HTMLDivElement
179181
}

0 commit comments

Comments
 (0)