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));
});

ギャラリーの概要を表示したくないので、ギャラリータグを避けようとしています。私のURLは単純な配列に保存されています。

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

この配列を写真スワイプにアタッチしたり、単純な for ループを実行したりすることは可能ですか? それとも別のアプローチがありますか?

事前にThx :)

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 に答える