react-spring-bottom-sheet
react-spring-bottom-sheet copied to clipboard
onSpringEnd It works too late !
I want to show something two different view in real time how get snap index real time ?
you could use the height info
<BottomSheer ref={sheetRef} {...props} />
// then in your code access to that ref and
useEffect(( ) => {
// height changed, do your staff
}, [sheetRef.current.height)
and if you read the docs, you will find support for this
export default function Example() {
const sheetRef = React.useRef()
return (
<BottomSheet
ref={sheetRef}
onSpringStart={() => {
console.log('Transition from:', sheetRef.current.height)
requestAnimationFrame(() =>
console.log('Transition to:', sheetRef.current.height)
)
}}
onSpringEnd={() =>
console.log('Finished transition to:', sheetRef.current.height)
}
/>
)
}