UNPKG

@freakycoder/animated-tabbar

Version:

A 60FPS animated tab bar with a variety of cool animation presets.

22 lines (21 loc) 708 B
import { useEffect } from 'react'; import { useSharedValue, withTiming } from 'react-native-reanimated'; export const useTabBarItemFocusTransition = ({ index, selectedIndex, duration, easing }) => { const position = useSharedValue(0); useEffect(() => { // This logic decides if the item should animate in or out based on the selectedIndex const isSelected = selectedIndex.value === index; position.value = withTiming(isSelected ? 1 : 0, { duration, easing }); }, [index, selectedIndex, duration, easing]); // We return the position to be used in animated styles or wherever necessary. return position; }; //# sourceMappingURL=useTabBarItemFocusTransition.js.map