davidtgq
davidtgq

Reputation: 4000

Photoswipe.js detect event when the pswp gallery is closed

When closing Photoswipe, it has some leftover elements on the DOM that breaks it, so I want to use jQuery to reset it every time it's closed. How can I get the event when Photoswipe closed?

Upvotes: 0

Views: 2850

Answers (2)

Nishal K.R
Nishal K.R

Reputation: 1130

You can use PhotoSwipe events.

// Event fire when Gallery starts closing
pswp.listen('close', function() { 
    // code here
});

// Even trigers when Gallery unbinds events
// (triggers before closing animation)
pswp.listen('unbindEvents', function() {
    // code here
});

// Event fires when only after the gallery is closed and closing animation finished.
pswp.listen('destroy', function() {
    // code here
});

Upvotes: 2

carl
carl

Reputation: 419

From the docs:

// After gallery is closed and closing animation finished.
// Clean up your stuff here.
pswp.listen('destroy', function() { });

Upvotes: 1

Related Questions