Open goldmerc opened 3 years ago
Looking at the code, I think this would work...
photoswipe.on('afterGoto', () => {
this.index = photoswipe.index;
});
H, just to add more info to this. We can also listen to change
event. By default afterGoto
event only listens to slide change that was initiated by next and prev arrow buttons. The change
event listener on the other hand listens to slide drag and keyboard initiated changes:
photoswipe.on('change', () => {
// do something here
});
Also I found the current index at:
photoswipe.pswp.currIndex
and photoswipe.pswp.currSlide.index
@lnfel Thank you! Was trying to find out how to get the current index and you saved me having to dig through the source code. I didn't see it anywhere in the docs.
When do you plan to write the API docs for v5?
Specifically, I need to listen to when the image changes and get the index of the new image.
Many thanks!