Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single instance of the gallery on the page (reuse) #1513

Closed
rdk01 opened this issue Apr 21, 2018 · 3 comments
Closed

Single instance of the gallery on the page (reuse) #1513

rdk01 opened this issue Apr 21, 2018 · 3 comments

Comments

@rdk01
Copy link

rdk01 commented Apr 21, 2018

There are many examples of how to use PhotoSwipe on its website, but if we take a closer look, all the examples are creating a new instance of the same gallery on every thumb/button click on the same page with the same gallery, because PhotoSwipe is destroyed when you close it.

I'm a bit confused with the idea of creating a new instance of the same gallery every time I want to display PhotoSwipe, because you need to repeat the same actions on every click:

  1. build the list of images
  2. configure options
  3. construct the gallery
  4. init it

Of course (and we definitely will) cache the image list, options, but the approach of constructing a totally new gallery on every click seems to be and is, by definition, very inefficient.

What is the logic behind such approach?

@gregorybolkenstijn
Copy link

Would love to know this as well, the current way to initialize PhotoSwipe suggests a user would only use it once?

@Cube707
Copy link

Cube707 commented Mar 2, 2021

Maybe someone is still interested in this:
I ran into the same Problem. Creating a new instance every time causes a lot of traffic if larger images are used and a user opens and closes a gallery multiple times.
I get that there are only three images beeing loaded, but still.
Shouldn't therebe an open methode and why is the destrying methode insepreable from the closing methode without editing the core code?

@dimsemenov
Copy link
Owner

This is fixed by v5 - #1749 , so closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants