0

我正在尝试将图像动态附加到 Photoswipe。

$('#imgholder').on('tap', function(event){  
  (function(window,PhotoSwipe){                                                                         var                                                                                        options = {
preventHide: true,
getImageSource: function(obj){
return obj.url;
},
getImageCaption: function(obj){
return obj.caption;
}
},
function(){
for (var i = 0; i < images.length-1; i++)
{
instance = PhotoSwipe.attach([{url:images[i]}],options);
}
}
instance.show(0);
}(window,window.Code.PhotoSwipe));
});

我试图避免使用图库标签,因为我不想显示图库概览。我的网址存储在一个简单的数组中。

var images = result.news[index].bilder_url.split("-,-");

是否可以将此数组附加到 photoswipe 或运行一个简单的 for 循环?还是有不同的方法?

提前谢谢:)

4

1 回答 1

0
(function(window, PhotoSwipe){
var 
   options = {},
   instance = PhotoSwipe.attach( window.document.querySelectorAll('#Gallery a'), options);
   instance.show(1);   
}(window, window.Code.PhotoSwipe));

这就是诀窍:)

在 PhotoSwipe 提供的示例中找到。

于 2013-04-24T13:13:07.923 回答