react-native-reanimated-progress-bar
Version:
React Native animated progress bar, using react-native-reanimated
18 lines • 898 B
JavaScript
import React from 'react';
import { View } from 'react-native';
import Animated from 'react-native-reanimated';
import styles from './styles';
import useOnLayout from './useOnLayout';
import useAnimatedColor from './animations/useAnimatedColor/useAnimatedColor';
import useAnimatedProgress from './animations/useAnimatedProgress/useAnimatedProgress';
const AnimatedProgress = ({ fill, current, total, style, progressStyle }) => {
const percent = current / total;
const [{ width }, onLayout] = useOnLayout();
const backgroundColor = useAnimatedColor(fill);
const translateX = useAnimatedProgress(width, percent);
return (<View style={[styles.container, style]} onLayout={onLayout}>
<Animated.View style={[styles.progress, { backgroundColor, transform: [{ translateX }] }, progressStyle]}/>
</View>);
};
export default AnimatedProgress;
//# sourceMappingURL=index.js.map