UNPKG

react-native-sortables

Version:

Powerful Sortable Components for Flexible Content Reordering in React Native

40 lines (39 loc) 1.18 kB
"use strict"; import { useAnimatedStyle } from 'react-native-reanimated'; import { usePortalContext } from '../PortalProvider'; import useItemZIndex from './useItemZIndex'; import useTeleportedItemPosition from './useTeleportedItemPosition'; export default function useTeleportedItemStyles(key, isActive, activationAnimationProgress) { const { portalOutletMeasurements } = usePortalContext() ?? {}; const zIndex = useItemZIndex(key, activationAnimationProgress); const position = useTeleportedItemPosition(key, isActive, activationAnimationProgress); return useAnimatedStyle(() => { if (!portalOutletMeasurements?.value || !position.value) { // This should never happen return { display: 'none' }; } const { pageX: outletX, pageY: outletY } = portalOutletMeasurements.value; const { x: itemX, y: itemY } = position.value; return { display: 'flex', position: 'absolute', transform: [{ translateX: itemX - outletX }, { translateY: itemY - outletY }], zIndex: zIndex.value }; }); } //# sourceMappingURL=useTeleportedItemStyles.js.map