photoswipe - adding images during gallery show

╄→尐↘猪︶ㄣ 提交于 2019-12-24 11:35:01

问题


I know it's simple to add images to a photoswipe list with jquery, but I can't figure out how to update the image list while browsing the gallery, i.e. without going back to the image list. An alternative (without jquery because it adds images directly to photoswipe instance) I found is to use the code below, but it seems that the only possibility to have the list updated while in the gallery is to go back to the first image (before going to the first image, everything is a mess). Is there any function to refresh the list while browsing the gallery?

for (i = 0; i < fileList.length; i++) { //add new image list
      console.log(fileList[i]);
      instance.cache.images.push(new Code.PhotoSwipe.Image.ImageClass(fileList[i], fileList[i].url, fileList[i].caption, ''));
    };

回答1:


You can add images to PhotoSwipe even when gallery is currently open.

Here is an example from documentation (see chapter Adding slides dynamically) where pswp is your PhotoSwipe object (what new PhotoSwipe() returns).

pswp.items.push({
  src: "path/to/image.jpg", 
  w:1200,
  h:500 
});

It works for me in PhotoSwipe v4.1.1



来源:https://stackoverflow.com/questions/15204346/photoswipe-adding-images-during-gallery-show

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!