Сайт Fakel Gym
https://fakelgym.cp.good-production.xyz/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.5 KiB
46 lines
1.5 KiB
document.addEventListener('DOMContentLoaded', function() {
|
|
const heroBlocks = document.querySelectorAll('.hero-block');
|
|
|
|
heroBlocks.forEach(function(block) {
|
|
const swiperContainer = block.querySelector('.swiper');
|
|
|
|
if (!swiperContainer) return;
|
|
|
|
const swiper = new Swiper(swiperContainer, {
|
|
slidesPerView: 1,
|
|
loop: true,
|
|
grabCursor: true,
|
|
on: {
|
|
slideChange: function () {
|
|
updatePagination(block, this.realIndex);
|
|
}
|
|
}
|
|
});
|
|
|
|
// Функция обновления пагинации
|
|
function updatePagination(block, activeIndex) {
|
|
const paginationItems = block.querySelectorAll('.pagination-item');
|
|
|
|
paginationItems.forEach((item, index) => {
|
|
item.setAttribute('data-active', index === activeIndex ? 'true' : 'false');
|
|
});
|
|
}
|
|
|
|
// Навигация
|
|
const prevBtn = block.querySelector('.custom-prev');
|
|
const nextBtn = block.querySelector('.custom-next');
|
|
|
|
if (prevBtn) {
|
|
prevBtn.addEventListener('click', () => swiper.slidePrev());
|
|
}
|
|
|
|
if (nextBtn) {
|
|
nextBtn.addEventListener('click', () => swiper.slideNext());
|
|
}
|
|
|
|
// Пагинация
|
|
block.querySelectorAll('.pagination-item').forEach((item, index) => {
|
|
item.addEventListener('click', () => swiper.slideToLoop(index));
|
|
});
|
|
});
|
|
}); |