Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Self.photoswipe = function() {
- var $pswp = $('.pswp')[0];
- $('.gallery-lists').each(function() {
- var $pic = $(this);
- $pic.find('a.photoswipe-link').click(function(event) {
- event.preventDefault();
- var $items = $pic.find('.gallery-item:not(.isotope-hidden)'),
- self = $(this),
- parent = self.closest('.gallery-item'),
- index = $items.index(parent),
- items = $pic.find('.gallery-item:not(.isotope-hidden)').get().map(function(item) {
- var $size = $(item).find('a.photoswipe-link').data('size').split('x');
- return {
- src: $(item).find('a.photoswipe-link').attr('href'),
- w: $size[0],
- h: $size[1]
- };
- }),
- options = {
- index: index,
- bgOpacity: 0.7,
- getThumbBoundsFn: function(index) {
- // See Options -> getThumbBoundsFn section of documentation for more info
- var thumbnail = self.find('img')[0], // find thumbnail
- pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
- rect = thumbnail.getBoundingClientRect();
- return {
- x: rect.left,
- y: rect.top + pageYScroll,
- w: rect.width
- };
- }
- };
- var lightBox = new PhotoSwipe($pswp, PhotoSwipeUI_Default, items, options);
- lightBox.init();
- return false;
- });
- });
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement