From 7aa203150fc1a2ec79c681c13f0d486d531746eb Mon Sep 17 00:00:00 2001 From: George Halkiadakis Date: Sun, 12 Mar 2023 23:57:48 +0200 Subject: error pages; js system to support back/front-end --- html/assets/js/plugins/gallery.js | 51 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 html/assets/js/plugins/gallery.js (limited to 'html/assets/js/plugins/gallery.js') diff --git a/html/assets/js/plugins/gallery.js b/html/assets/js/plugins/gallery.js new file mode 100644 index 0000000..6ac147a --- /dev/null +++ b/html/assets/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 -- cgit v1.2.3