UNPKG

@freakycoder/animated-tabbar

Version:

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

29 lines (27 loc) 956 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useTabBarItemFocusTransition = void 0; var _react = require("react"); var _reactNativeReanimated = require("react-native-reanimated"); const useTabBarItemFocusTransition = ({ index, selectedIndex, duration, easing }) => { const position = (0, _reactNativeReanimated.useSharedValue)(0); (0, _react.useEffect)(() => { // This logic decides if the item should animate in or out based on the selectedIndex const isSelected = selectedIndex.value === index; position.value = (0, _reactNativeReanimated.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; }; exports.useTabBarItemFocusTransition = useTabBarItemFocusTransition; //# sourceMappingURL=useTabBarItemFocusTransition.js.map