@attio/react-native-bottom-sheet-toolbox
Version:
21 lines (15 loc) • 656 B
text/typescript
import {useAnimatedStyle} from "react-native-reanimated"
import {useBottomSheetToolboxInternalContext} from "../context"
export function useAnimatedSheetStyle() {
const {currentPositionSharedValue, wrapperHeightSharedValue} =
useBottomSheetToolboxInternalContext()
return useAnimatedStyle(() => {
const wrapperHeight = wrapperHeightSharedValue.get()
if (wrapperHeight === null) return {}
const translateY = wrapperHeight - currentPositionSharedValue.get()
return {
opacity: 1,
transform: [{translateY}],
}
}, [currentPositionSharedValue, wrapperHeightSharedValue])
}