Advertisement
Guest User

Untitled

a guest
Feb 17th, 2020
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. Self.photoswipe = function(){
  2. var $pswp = $('.pswp')[0];
  3.  
  4. $('.gallery-lists').each(function() {
  5. var $pic = $(this),
  6. getItems = function() {
  7. var items = [];
  8. $pic.find('.gallery-item:not(.isotope-hidden):not(.slick-cloned) a.photoswipe-link').each(function() {
  9. var $href = $(this).attr('href'),
  10. $size = $(this).data('size').split('x'),
  11. $width = $size[0],
  12. $height = $size[1];
  13.  
  14. var item = {
  15. src : $href,
  16. w : $width,
  17. h : $height
  18. };
  19.  
  20. items.push(item);
  21. });
  22. return items;
  23. };
  24.  
  25.  
  26. $pic.find('a.photoswipe-link').click( function(event) {
  27. event.preventDefault();
  28. var items = getItems();
  29. var slick = $('.gallery-element').data('slick');
  30. var $index = $(this).data('index'),
  31. $items = $pic.find('.gallery-item:not(.isotope-hidden):not(.slick-cloned)'),
  32. parent = $(this).closest('.gallery-item'),
  33. index = $items.index(parent);
  34. var options = {
  35. index: index,
  36. bgOpacity: 0.7,
  37. showHideOpacity: true
  38. };
  39.  
  40. // Initialize PhotoSwipe
  41. var lightBox = new PhotoSwipe($pswp, PhotoSwipeUI_Default, items, options);
  42. lightBox.init();
  43. });
  44. });
  45. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement