Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding images dynamically to photoswipe

Is there a way to add images dynamically to a photoswipe gallery after it is created.

The situation is this.

I'm fetching image urls from the sever and showing them in a gallery. As the items are downloaded the anchor and img elements are added to the page. I would like to be able to at that same time append each to the photoswipe gallery.

currently in the element callback (after the image has been loaded and elements appended) I have

 $elements.photoSwipe({ enableMouseWheel: false , enableKeyboard: false });

This works except it creates each element in it's own gallery. Is there a way to get a handle to an existing gallery and just append to it?

like image 921
Justin Ohms Avatar asked May 15 '12 17:05

Justin Ohms


1 Answers

if(this.photoSwipe == undefined){
   this.photoSwipe = $elements.photoSwipe(photoSwipeOptions);
}else{
    this.photoSwipe.append($elements);  //use jQuery append
}
like image 80
Justin Ohms Avatar answered Oct 12 '22 22:10

Justin Ohms