UNPKG

@td-design/react-native

Version:

react-native UI组件库

26 lines 726 B
import { useEffect } from 'react'; import { useAnimatedProps, useSharedValue, withTiming } from 'react-native-reanimated'; export default function useLineProgress(_ref) { let { width = 0, strokeWidth = 0, value = 0, unit } = _ref; const progress = useSharedValue(0); const textLabel = useSharedValue(''); useEffect(() => { progress.value = withTiming(value * width / 100 - strokeWidth / 2, { duration: 600 }); textLabel.value = unit ? `${value}${unit}` : `${value}`; }, [value, width, strokeWidth, unit]); const animatedProps = useAnimatedProps(() => ({ x2: progress.value })); return { textLabel, animatedProps }; } //# sourceMappingURL=useLineProgress.js.map