Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. Self.photoswipe = function() {
  2.  
  3. var $pswp = $('.pswp')[0];
  4.  
  5. $('.gallery-lists').each(function() {
  6. var $pic = $(this);
  7. $pic.find('a.photoswipe-link').click(function(event) {
  8. event.preventDefault();
  9. var $items = $pic.find('.gallery-item:not(.isotope-hidden)'),
  10. self = $(this),
  11. parent = self.closest('.gallery-item'),
  12. index = $items.index(parent),
  13. items = $pic.find('.gallery-item:not(.isotope-hidden)').get().map(function(item) {
  14. var $size = $(item).find('a.photoswipe-link').data('size').split('x');
  15. return {
  16. src: $(item).find('a.photoswipe-link').attr('href'),
  17. w: $size[0],
  18. h: $size[1]
  19. };
  20. }),
  21. options = {
  22. index: index,
  23. bgOpacity: 0.7,
  24. getThumbBoundsFn: function(index) {
  25. // See Options -> getThumbBoundsFn section of documentation for more info
  26. var thumbnail = self.find('img')[0], // find thumbnail
  27. pageYScroll = window.pageYOffset || document.documentElement.scrollTop,
  28. rect = thumbnail.getBoundingClientRect();
  29.  
  30. return {
  31. x: rect.left,
  32. y: rect.top + pageYScroll,
  33. w: rect.width
  34. };
  35. }
  36. };
  37.  
  38. var lightBox = new PhotoSwipe($pswp, PhotoSwipeUI_Default, items, options);
  39. lightBox.init();
  40. return false;
  41. });
  42. });
  43. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement