-1

There are 4 images. Whenever I swap them, I want to have a smooth animated transition. How may I apply that in my current code?

Click here to view the code

Also please check out the 2nd screenshot. I don't want the left swap option to be active when there is no image. But it swaps 1 extra time and stops. What is wrong with my logic?

Here is the screenshot

Hossain
  • 17
  • 9

1 Answers1

0

Have a try with the below code:

const handleSwipeLeft = () => {
    if (activeImg < totalImage - 1) {
        setActiveImage(currActive => currActive + 1)
    }
}

as the length greater than the index.

Jignesh Mayani
  • 6,937
  • 1
  • 20
  • 36