while PhotoSwipe has been fantastic so far just these minor issues that I can't seem to get around
I initialize PhotoSwipe as follows
formPhoto.gallery = window.Code.PhotoSwipe.attach( images, options);
And inside a Gallery, a user can choose whether to delete an image or not via
Once the delete button is pushed this is run
formPhoto.gallery.cache.images.splice(e.target.currentIndex,1);
delete formPhoto.activeObj.value[e.target.originalImages[e.target.currentIndex].id];
if(formPhoto.gallery.cache.images.length == 0)
formPhoto.gallery.hide();
else
formPhoto.gallery.carousel.show( 0 );
Now this works mostly fine, except in 2 cases.
- If you are below 3 photos, it breaks the slide event (on slide right) - The image slides onto a black screen. If you delete and only have 1 image left, you can't even view the image properly it just bounces back onto a black screen.
- If you add images back into the gallery again, the old images that were deleted are shown again
It is reinitiated using
images = [];
for(var x in formPhoto.activeObj.value)
images.push({url: formPhoto.activeObj.value[x].file, id:x});
formPhoto.gallery = window.Code.PhotoSwipe.attach( images, options);
If you want, I can try grab a recording of whats going on. I'm not sure how to solve this, I've looked around on the https://github.com/codecomputerlove/PhotoSwipe/issues and google but nothing helpful.
All I really want to do is just remove an image from the Gallery (its viewed in Exclusive Mode only)