How to set scroll position after close image?

170 views Asked by At

I'm using photoswipe to generate photo gallery on my website. The gallery is horizontal orientation. How to set position scroll?

JavaScript code

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

Here's code !

0

There are 0 answers