Skip to content

Instantly share code, notes, and snippets.

@renso3x
Last active November 15, 2017 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save renso3x/08dcfef459c9ecf5e3a44d53ecb48674 to your computer and use it in GitHub Desktop.
Save renso3x/08dcfef459c9ecf5e3a44d53ecb48674 to your computer and use it in GitHub Desktop.
import React from 'react';
import { Animated } from 'react-native';
import CircularProgress from './CircularProgress';
const AnimatedProgress = Animated.createAnimatedComponent(CircularProgress);
class AnimatedCircularProgress extends React.Component {
constructor() {
super();
this._animatedValue = new Animated.Value(0);
this._animatedValue.addListener(({ value }) => this._value = value);
}
start(duration) {
this.duration = duration;
Animated.timing(this._animatedValue, {
toValue: 360,
duration: this.duration,
}).start(() => this._animatedValue.setValue(0));
}
restartAnimation() {
this._animatedValue.setValue(0);
Animated.timing(this._animatedValue, {
useNativeDriver: false,
toValue: 360,
duration: this.duration,
}).start(() => this._animatedValue.setValue(0));
}
stop() {
this._animatedValue.stopAnimation();
}
continue() {
Animated.timing(this._animatedValue, {
toValue: 360,
duration: this.duration,
}).start(() => this._animatedValue.setValue(0));
}
render() {
return (
<AnimatedProgress
value={this._animatedValue}
{...this.props}
/>
)
}
}
export default AnimatedCircularProgress;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment