]> git.ipfire.org Git - thirdparty/bulma.git/commitdiff
Add photoswipe
authorJeremy Thomas <bbxdesign@gmail.com>
Tue, 11 Jun 2024 02:03:31 +0000 (03:03 +0100)
committerJeremy Thomas <bbxdesign@gmail.com>
Tue, 11 Jun 2024 02:03:31 +0000 (03:03 +0100)
docs/assets/javascript/shop.js
docs/shop.html

index bcd08fd21e9beda618eec1cd1647f26cbb562042..2c5f208246e66c9bb0029366900253cfe9723a6f 100644 (file)
@@ -533,11 +533,22 @@ document.addEventListener("DOMContentLoaded", () => {
 
       if (images) {
         images.forEach(img => {
-          const $figure = El("shop-product-image image is-square", "figure");
+          const $figure = El("shop-product-image image is-square", "a");
+          $figure.href = img.url;
+          $figure.dataset.pswpHeight = img.height;
+          $figure.dataset.pswpWidth = img.width;
+          $figure.target = "_blank";
           const $img = document.createElement("img");
           $img.src = img.url;
           $figure.appendChild($img);
           $carousel.appendChild($figure);
+
+          const lightbox = new window.PhotoSwipeLightbox({
+            gallery: '.shop-product-image',
+            pswpModule: window.PhotoSwipe
+          });
+
+          lightbox.init();
         });
 
         $images.appendChild($carousel);
index 1bce695ce118785ee0e2c87eedf2191ee5b95599..5babbbbc2095c8034a1b65810218fc95b784d937 100644 (file)
@@ -9,6 +9,8 @@ breadcrumb:
   - shop
 ---
 
+<link rel="stylesheet" type="text/css" href="https://unpkg.com/photoswipe@5.4.4/dist/photoswipe.css">
+
 <style type="text/css">
   :root {
     --shop-duration: 500ms;
@@ -287,8 +289,9 @@ breadcrumb:
 
   .shop-product-image {
     flex-shrink: 0;
-    cursor: pointer;
+    cursor: zoom-in;
     overflow: hidden;
+    outline: none !important;
   }
 
   .shop-product-image img {
@@ -298,7 +301,7 @@ breadcrumb:
   }
 
   .shop-product-images:hover img {
-    transform: scale(1.1);
+    transform: scale(1.04);
   }
 
   .shop-product-heading {
@@ -496,4 +499,6 @@ breadcrumb:
 </div>
 
 <script src="https://unpkg.com/@shopify/storefront-api-client@1.0.0/dist/umd/storefront-api-client.min.js"></script>
+<script src="https://unpkg.com/photoswipe@5.4.4/dist/umd/photoswipe.umd.min.js"></script>
+<script src="https://unpkg.com/photoswipe@5.4.4/dist/umd/photoswipe-lightbox.umd.min.js"></script>
 <script type="text/javascript" src="{{ site.url }}/assets/javascript/shop.js"></script>