react-spring-bottom-sheet icon indicating copy to clipboard operation
react-spring-bottom-sheet copied to clipboard

onSpringEnd It works too late !

Open behnam-maqsudi opened this issue 4 years ago • 2 comments

I want to show something two different view in real time how get snap index real time ?

behnam-maqsudi avatar Sep 09 '21 14:09 behnam-maqsudi

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)

Guiw5 avatar Oct 18 '21 16:10 Guiw5

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)
      }
    />
  )
}

Guiw5 avatar Oct 18 '21 16:10 Guiw5