I’ve dealt with almost identical question recently. So, there is a sample code for this and listing of progression. Maybe, you will find one of them useful.
Link to original question
I am trying to finish a slider for a gallery of images and all I’m missing is the prev/next button functionality. Right now the prev button is working but there’s one issue. Here’s the problem, I have a gallery of images, when I click on them a popup shows up displaying the image that was clicked. However, if I click any image that isn’t the first one of the array and click the prev button, it’s gonna take me all they way back to the last image of the array, instead the prev button should take m…
Link to the code samples
https://codepen.io/gunhoo93/pen/djoxdB?editors=1010
https://codepen.io/gunhoo93/pen/mjRoKd?editors=1010
https://codepen.io/gunhoo93/pen/qyxgvK?editors=1010