summaryrefslogtreecommitdiff
path: root/html/content/js/Plugins/gallery.js
diff options
context:
space:
mode:
Diffstat (limited to 'html/content/js/Plugins/gallery.js')
-rw-r--r--html/content/js/Plugins/gallery.js51
1 files changed, 51 insertions, 0 deletions
diff --git a/html/content/js/Plugins/gallery.js b/html/content/js/Plugins/gallery.js
new file mode 100644
index 0000000..6ac147a
--- /dev/null
+++ b/html/content/js/Plugins/gallery.js
@@ -0,0 +1,51 @@
+$$plugins.define('gallery', ['swiper-bundle', 'domHelper'], function (element, options, Swiper, $) {
+ var $galleryImg = $('.gallery__figure img'),
+ thumbs = document.querySelector('.galleryThumbs'),
+ sliderModal = document.querySelector('.gallerySliderModal'),
+ $image;
+
+ var swiperThumbs = new Swiper(".galleryThumbs", {
+ direction: "horizontal",
+ freeMode: true,
+ init: false,
+ slidesPerView: 4,
+ spaceBetween: 8,
+ speed: 800,
+ watchSlidesProgress: true,
+ pagination: {
+ el: '.swiper-pagination',
+ },
+ breakpoints: {
+ 768: {
+ slidesPerView: 5,
+ spaceBetween: 17,
+ }
+ },
+ });
+
+ var swiperMain = new Swiper(".galleryMainImg", {
+ init: false,
+ loop: true,
+ navigation: {
+ nextEl: ".swiper-button-next",
+ prevEl: ".swiper-button-prev",
+ },
+ speed: 800,
+ thumbs: {
+ swiper: swiperThumbs,
+ },
+ });
+
+ $galleryImg.on('click', function () {
+ if (!thumbs.classList.contains('swiper-initialized')) {
+ swiperThumbs.init();
+ swiperMain.init();
+ }
+ sliderModal.classList.add('open');
+ $image = $(this).parents('.gallery__figure');
+ swiperMain.slideTo($image.index() + 1, 0);
+
+ //document.documentElement.classList.add('noScroll');
+
+ });
+}); \ No newline at end of file