Last active
November 15, 2017 23:27
-
-
Save renso3x/08dcfef459c9ecf5e3a44d53ecb48674 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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