Skip to content

Instantly share code, notes, and snippets.

@fernandatoledo
Last active July 1, 2020 16:25
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 fernandatoledo/4e0b35f95745bdc0ea3ab8ba24cc1776 to your computer and use it in GitHub Desktop.
Save fernandatoledo/4e0b35f95745bdc0ea3ab8ba24cc1776 to your computer and use it in GitHub Desktop.
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