UNPKG

react-native-micro-interactions

Version:

Effortlessly enhance your React Native components with subtle micro-interactions and animations.

47 lines (46 loc) 1.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.dropIn = void 0; var _reactNativeReanimated = require("react-native-reanimated"); var _animOptionsFilter = require("../utils/animOptionsFilter.js"); var _react = require("react"); const dropIn = (config, props) => { const animationOptions = (0, _animOptionsFilter.filterDropInAnimOptions)(config, props); const opacity = (0, _reactNativeReanimated.useSharedValue)(0); const translateY = (0, _reactNativeReanimated.useSharedValue)(50); const runIndividualAnimation = (0, _react.useCallback)(() => { opacity.value = 0; translateY.value = 50; if (animationOptions.withBounce) { translateY.value = (0, _reactNativeReanimated.withSpring)(0, { damping: animationOptions.damping }); opacity.value = (0, _reactNativeReanimated.withTiming)(1, { duration: animationOptions.duration }); } else { opacity.value = (0, _reactNativeReanimated.withTiming)(1, { duration: animationOptions.duration }); translateY.value = (0, _reactNativeReanimated.withTiming)(0, { duration: animationOptions.duration }); } }, [animationOptions, opacity, translateY]); const animatedStyle = (0, _reactNativeReanimated.useAnimatedStyle)(() => { return { opacity: opacity.value, transform: [{ translateY: translateY.value }] }; }, [opacity, translateY]); return { animatedStyle, runIndividualAnimation }; }; exports.dropIn = dropIn; //# sourceMappingURL=drop_in.js.map