UNPKG

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

Version:
34 lines (33 loc) 1.49 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useBottomSheetIsReady = useBottomSheetIsReady; var _reactNativeReanimated = require("react-native-reanimated"); var _context = require("../context"); /** * An internal check to determine if the bottom-sheet has been initialized and * is ready to display. * * The argument outerIsReady is offered as a way to allow the consumer to extend * the check to include other conditions. */ function useBottomSheetIsReady(outerIsReady) { const { normalizedSnapPointsSharedValue, wrapperHeightSharedValue, childrenHeightSharedValue, isReadySharedValue } = (0, _context.useBottomSheetToolboxInternalContext)(); (0, _reactNativeReanimated.useAnimatedReaction)(() => { const isOuterReady = typeof outerIsReady === "boolean" ? outerIsReady : outerIsReady.get(); const isNormalizedSnapPointsReady = normalizedSnapPointsSharedValue.get() !== null; const isWrapperHeightReady = wrapperHeightSharedValue.get() !== null; const isChildrenHeightReady = childrenHeightSharedValue.get() !== null; return isOuterReady && isNormalizedSnapPointsReady && isWrapperHeightReady && isChildrenHeightReady; }, newIsReady => { if (newIsReady === isReadySharedValue.get()) return; isReadySharedValue.set(newIsReady); }, [outerIsReady, childrenHeightSharedValue, wrapperHeightSharedValue, normalizedSnapPointsSharedValue]); } //# sourceMappingURL=use-bottom-sheet-is-ready.js.map