UNPKG

react-native-sortables

Version:

Powerful Sortable Components for Flexible Content Reordering in React Native

25 lines (21 loc) 651 B
import type { SharedValue } from 'react-native-reanimated'; import { useDerivedValue } from 'react-native-reanimated'; import { useCommonValuesContext } from '../CommonValuesProvider'; export default function useItemZIndex( key: string, activationAnimationProgress: SharedValue<number> ): SharedValue<number> { const { activeItemKey, prevActiveItemKey } = useCommonValuesContext(); return useDerivedValue<number>(() => { if (activeItemKey.value === key) { return 3; } if (prevActiveItemKey.value === key) { return 2; } if (activationAnimationProgress.value > 0) { return 1; } return 0; }); }