dimsemenov / PhotoSwipe

JavaScript image gallery for mobile and desktop, modular, framework independent
http://photoswipe.com
MIT License
24.18k stars 3.31k forks source link

Multiple galleries - different pwsp instances #881

Open ghost opened 9 years ago

ghost commented 9 years ago

Hi,

I hope you can help me with my issue! I am implementing photoswipe inside a jquerymobile site.

I have an odd issue... I have a need for 2 separate photoswipe galleries, but they aren't both visible at the same time. This means that I have the .pwsp class initiated twice within my document.

The pagination of jQuery Mobile has me putting all code for the site on one HTML file and using page div's.

I've tried reading all the documentation but can't get it to work properly on the 2nd album. How can I have 2 separate pwsp class div's that each load a different gallery? Do I initialise via an ID?

Any help you can give is greatly appreciated!

dimsemenov commented 9 years ago

You can reuse one .pswp element between two galleries. Or add it dynamically, just before PhotoSwipe is open. It's used on when PhotoSwipe is.

ghost commented 9 years ago

Thank you for your prompt reply!

I've managed to set the pswp element into it's own variable so it can by dynamically added to the relevant div when photoswipe is opened.

I have another issue now though... on one of the 2 sections in which I launch photoswipe:

The first time I load the gallery all of the controls are in the top corner and nothing is formatted correctly.

However the 2nd time I go back and reload that page it's formatted perfectly... I'm not sure why though! Any help is greatly appreciated!