Search code examples
javascriptphotoswipe

Listen for swipe/touch events with Photoswipe gallery plugin


There is one particular photoswipe event that listen when the gallery has changed.

// After slides change
// (after content changed)
pswp.listen('afterChange', function() { });

I am wondering if there might be a way to detect from which direction the change apeared, so from left or right. Does anyone have an idea?

http://photoswipe.com/documentation/api.html


Solution

  • You may compare indexes in this event handler, pswp.getCurrentIndex() will return you current slide index.