UNPKG

@attio/react-native-bottom-sheet-toolbox

Version:
29 lines (28 loc) 1.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useBottomSheetDirection = useBottomSheetDirection; var _reactNativeReanimated = require("react-native-reanimated"); var _context = require("../context"); /** * Returns the direction the bottom sheet is moving in. * +1 = moving up * 0 = not moving * -1 = moving down */ function useBottomSheetDirection() { const { currentPositionSharedValue } = (0, _context.useBottomSheetToolboxInternalContext)(); const lastPositionSharedValue = (0, _reactNativeReanimated.useSharedValue)(0); return (0, _reactNativeReanimated.useDerivedValue)(() => { const currentPosition = currentPositionSharedValue.get(); const lastPosition = lastPositionSharedValue.get(); const delta = currentPosition - lastPosition; const direction = Math.sign(delta); lastPositionSharedValue.set(currentPosition); return direction; }, [currentPositionSharedValue]); } //# sourceMappingURL=use-bottom-sheet-direction.js.map