I have tried looking into multiple tutorials for the same but I could not find the same.
I have multiple images in assets like :
const animImages = [
require('..//../img/ic_1.png'),
require('..//../img/ic_2.png'),
require('..//../img/ic_3.png'),
require('..//../img/ic_4.png'),
require('..//../img/ic_5.png'),
require('..//../img/ic_6.png'),
];
export default animImages;
What I want to do is based on a button press, I wanted to loop these images one by one and show it inside a view. I created a variable and tried to conditionally render the component based on the same. Here is the code snippet.
<>
{animImages.map(img => <Image source={img} />)}
</>
This lets me render all the images, however, I want to loop over the images and render them 1 by 1 so that it looks like an animation. Can anyone help with the same.
Thanks
EDIT : I want to loop the images at the same place where the button was, I can take care of the same using the conditional rendering. But I want it to loop for certain seconds and then redisplay the button.
Here is what I have :
{componentProps.showAnimation ?
<View style={styles.elevatedView}>
<TouchableOpacity
onPress={() => {
console.log("button pressed");
// stop the image loop
}}
>
{The loop for images comes here }
</TouchableOpacity>
</View>
:
<View style={styles.elevatedView}>
<IconsRender
icon={acomponentProps.icons.icon}
/>
</View>
}
2
Answers
That is straightforward you should be able to implement that on your own.
Nevertheless I am gonna provide an example based on (https://github.com/chagasaway/react-native-fading-slides)
Example:
You could really use the simple react native animation to achieve that. An example would be :