codecomputerlove/PhotoSwipe — Issue #174: Create multiple gallerys with exclusive mode no thumbnails.
Author: andreb07
Created: 2011-10-26 18:14:34+00:00
State: open

Hello guys.
First of all, congrats for this great plugin :)

I have been messing around with this and trying to adapt the plugin for my project, but unfortunately i cant seem to find the solution...if there is one :(

I am using JQuery Mobile and i need to have 2 slideshows in my project with no thumbnails. I can insert one slideshow with no problems, but how can i have another slideshow (with different images) in the same project without getting always this error?

Code.PhotoSwipe.activateInstance: Unable to active instance as another instance is already active

Here is the code that i use to add one slideshow:

$('div.gallery-page-produtos')
.live('pagebeforeshow', function(e){

photoSwipeInstance = PhotoSwipe.getInstance('products');

if (typeof photoSwipeInstance != "undefined" && photoSwipeInstance != null) {
$('.ps-document-overlay').fadeIn();
$('.ps-uilayer').fadeIn();
$('.ps-carousel').fadeIn();
}
else
{
options = {
imageScaleMethod:'zoom',
allowUserZoom:false,
autoStartSlideshow:true,
captionAndToolbarHide:true,
enableKeyboard:false,
enableMouseWheel:false,
preventHide: true,
margin:0,
maxUserZoom:0,
minUserZoom:0,
getImageSource: function(obj){
return obj.url;
},
getImageCaption: function(obj){
return false
}
},
instance = PhotoSwipe.attach(
[
{ url: 'images/full/001.jpg'},
{ url: 'images/full/002.jpg'},
{ url: 'images/full/003.jpg'},
{ url: 'images/full/004.jpg'},
{ url: 'images/full/005.jpg'},
{ url: 'images/full/006.jpg'}
],
options,
('products')
);

instance.show(0);
}
})

.live('pagebeforehide', function(e){

$('.ps-document-overlay').fadeOut();
$('.ps-uilayer').fadeOut();
$('.ps-carousel').fadeOut();

});

On page hide i'm not "killing" the gallery, i'm just hiding it. Is this the problem? Do i have to clear all instances before creating a new one? Is there another way to do this?

If someone could help me out i would be grateful.
Thanks in advance