关闭图像后如何设置滚动位置?

时间:2015-06-17 13:40:04

标签: javascript photoswipe

我正在使用photoswipe在我的网站上生成照片库。画廊是水平方向。如何设置位置滚动?

JavaScript代码

var initPhotoSwipeFromDOM = function(gallerySelector) {


    // Pass data to PhotoSwipe and initialize it
    gallery = new PhotoSwipe( pswpElement, PhotoSwipeUI_Default, items, options);
  //gallery.listen('close', function() { alert('close') });
  //gallery.listen('mouseUsed', function() { });
    gallery.init();
};

// loop through all gallery elements and bind events
var galleryElements = document.querySelectorAll( gallerySelector );

for(var i = 0, l = galleryElements.length; i < l; i++) {
    galleryElements[i].setAttribute('data-pswp-uid', i+1);
    galleryElements[i].onclick = onThumbnailsClick;
}

// Parse URL and open gallery if it contains #&pid=3&gid=1
var hashData = photoswipeParseHash();
if(hashData.pid && hashData.gid) {
    openPhotoSwipe( hashData.pid ,  galleryElements[ hashData.gid - 1 ], true, true );
}
};
// execute above function
initPhotoSwipeFromDOM('.my-gallery');

这是code

0 个答案:

没有答案