Last active
July 1, 2020 16:25
-
-
Save fernandatoledo/4e0b35f95745bdc0ea3ab8ba24cc1776 to your computer and use it in GitHub Desktop.
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 from 'react'; | |
import { Animated } from 'react-native'; | |
import { | |
useAnimate, | |
useAnimateSequence, | |
} from '@rootstrap/react-native-use-animate'; | |
// Other style and dimension imports | |
const SequenceAnimatedBox = () => { | |
// Be aware: animate should be false for nested animations | |
const config = { duration: 1000, animate: false }; | |
const step1 = useAnimate({ fromValue: 0, toValue: WIDTH - BOX_SIZE, ...config }); | |
const step2 = useAnimate({ fromValue: 0, toValue: HEIGHT - BOX_SIZE, ...config }); | |
useAnimateSequence({ animations: [step1, step2], iterations: -1 }); | |
return ( | |
<Animated.View | |
style={[ | |
styles.box, | |
{ | |
left: step1.animatedValue, | |
top: step2.animatedValue, | |
}, | |
]} | |
/> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment