diff --git a/wp-content/themes/cosmopet/modules/layout/assets/js/gp-main.js b/wp-content/themes/cosmopet/modules/layout/assets/js/gp-main.js index 7cc2a7b..1419120 100644 --- a/wp-content/themes/cosmopet/modules/layout/assets/js/gp-main.js +++ b/wp-content/themes/cosmopet/modules/layout/assets/js/gp-main.js @@ -415,24 +415,34 @@ if (document.querySelector('.header').classList.contains('white')) { // scroll document.addEventListener('DOMContentLoaded', function () { - var carousels = document.querySelectorAll('.carousel'); - - if (carousels.length) { - var options = { - numVisible: window.innerWidth > 421 ? 5 : 3, - }; - var instances = M.Carousel.init(carousels, options); - - document.querySelectorAll('.about_slider_nav').forEach(function (btn) { + /* start: aboutSlider */ + var slider = carousel_init(); + function carousel_init() { + var carousel = document.querySelectorAll('.carousel'); + if (window.innerWidth > 421) { + var options = { + numVisible: 5, + // indicators: true, + } + } else if (window.innerWidth < 421) { + var options = { + numVisible: 3, + // indicators: true, + } + } + var instances = M.Carousel.init(carousel, options); + document.querySelectorAll('.about_slider_nav').forEach(btn => { btn.addEventListener('click', function (e) { - const instance = instances[0]; - if (btn.classList.contains('next')) { - instance.next(); - } else { - instance.prev(); + // window.t = e.target.closest('button') + // console.log(t) + if (e.target.closest('button').classList.contains('next')) { + instances[0].next(); + }else{ + instances[0].prev(); } }); }); + return instances; } });