@crossed/ui
Version:
A universal & performant styling library for React Native, Next.js & React
28 lines (27 loc) • 786 B
JavaScript
import { jsx } from "react/jsx-runtime";
import Animated, {
interpolate,
useAnimatedStyle,
withTiming
} from "react-native-reanimated";
import { styles } from "./styles";
import { useContext } from "react";
import { localContext } from "./context";
const Thumb = () => {
const { value, duration, height, width } = useContext(localContext);
const thumbAnimatedStyle = useAnimatedStyle(() => {
const moveValue = interpolate(
value ? 1 : 0,
[0, 1],
[0, width.value - height.value]
);
return {
transform: [{ translateX: withTiming(moveValue, { duration }) }]
};
}, [value]);
return /* @__PURE__ */ jsx(Animated.View, { style: [styles.thumb.style().style, thumbAnimatedStyle] });
};
export {
Thumb
};
//# sourceMappingURL=Thumb.js.map