From the course: React Native Essential Training

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Swiping left and right

Swiping left and right - React Native Tutorial

From the course: React Native Essential Training

Start my 1-month free trial

Swiping left and right

- [Instructor] While the user is swiping an image, the usual behavior of swiping is that the X position of the image is going to change in the same direction that we are swiping to. To make that happen, we can use the animated library. So I'll basically change the image component here to be an animated image, animated.image and we need to create an animated value. So let's do that right here before the image responder, we'll call this value image X position just like the title X position. So this is going to be a new animated value. It's a single value. We don't need an X and Y and it starts from zero. Now that we have an animated value, we can use it as the left property on the animated image component. So we already have a style for the image. I'll change that into an array, and we'll add a new object here. This object will have the left property to be this .image X position, just like that. So we now have an…

Contents