var kalmPhotoSwipeConfig = window.kalmInnPhotoSwipe || { lightboxUrl: 'https://cdn.jsdelivr.net/npm/photoswipe@5.4.4/dist/photoswipe-lightbox.esm.js', coreUrl: 'https://cdn.jsdelivr.net/npm/photoswipe@5.4.4/dist/photoswipe.esm.js' }; import(kalmPhotoSwipeConfig.lightboxUrl).then(function (module) { var PhotoSwipeLightbox = module.default; document.querySelectorAll('[data-kalm-gallery]').forEach(function (gallery) { gallery.querySelectorAll('.kalm-gallery__item').forEach(function (item) { item.addEventListener('mousemove', function (event) { var rect = item.getBoundingClientRect(); var x = ((event.clientX - rect.left) / rect.width - 0.5) * -10; var y = ((event.clientY - rect.top) / rect.height - 0.5) * -10; item.style.setProperty('--kalm-gallery-hover-x', x + 'px'); item.style.setProperty('--kalm-gallery-hover-y', y + 'px'); }); item.addEventListener('mouseleave', function () { item.style.removeProperty('--kalm-gallery-hover-x'); item.style.removeProperty('--kalm-gallery-hover-y'); }); }); var lightbox = new PhotoSwipeLightbox({ gallery: gallery, children: 'a', pswpModule: function () { return import(kalmPhotoSwipeConfig.coreUrl); } }); lightbox.init(); }); });