Created
October 28, 2021 09:31
-
-
Save davidsharp/3827bf12eca95acaadb83c565993594b to your computer and use it in GitHub Desktop.
An old animated sync icon, for an old version of React Native (0.40.0)
This file contains 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, { | |
PropTypes, Component | |
} from 'react'; | |
import { | |
Animated, Easing | |
} from 'react-native'; | |
// BYO sync icon | |
const SYNC = require('../images/sync.png') | |
class AnimatedSync extends Component { | |
state={spinValue:new Animated.Value(0)} | |
constructor(props){ | |
super(props); | |
console.log('AnimatedSync :::', props, this.state) | |
this.animate() | |
} | |
animate=()=>( | |
this.state.spinValue.setValue(0), | |
Animated.timing( | |
this.state.spinValue, | |
{ | |
toValue: 5, | |
duration: 3000, | |
easing: Easing.linear, | |
useNativeDriver: true, | |
} | |
).start(this.animate) | |
) | |
render(){ | |
const spin = this.state.spinValue.interpolate({ | |
//inputRange: [0, 0.05, 0.1, 0.2, 1, 10], | |
inputRange: [0, 0.1, 0.2, 0.4, 1, 5], | |
outputRange: ['0deg', '-20deg', '-30deg', '0deg', '360deg', '360deg'] | |
}) | |
return ( | |
<Animated.Image source={SYNC} style={[ | |
(this.props.statusButtonIconStyle || styles.defaultImageStyle), | |
{ width: 23, height: 29, resizeMode: 'contain', transform: [{rotate: spin}] }]} > | |
</Animated.Image> | |
); | |
} | |
} | |
export default AnimatedSync |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This was originally used in a button that showed a static image using a clockwise arrow (something like ⟳), and when pressed would animate to indicate that the syncing was in progress.