carhop__plugins__PROD-DEV/plugins/dynamiques-blocks/blocks/dernieres-dynamiques/build/dernieres-dynamiques/view.js
Antoine M 01a81a3fcc
All checks were successful
continuous-integration/drone/push Build is passing
FEATURE Opitimizing aspect and swiper configuration
2025-06-19 15:35:09 +02:00

63 lines
1.9 KiB
JavaScript

/******/ (() => { // webpackBootstrap
/*!******************************************!*\
!*** ./src/dernieres-dynamiques/view.js ***!
\******************************************/
document.addEventListener("DOMContentLoaded", function () {
const currentBlock = document.querySelector(".block-dernieres-dynamiques");
if (!currentBlock) return;
const swiperFraction = currentBlock.querySelector(".swiper-pagination-fraction");
const slides = currentBlock.querySelectorAll(".swiper-slide");
const slideCount = slides.length;
swiperFraction.textContent = `Article n°1 sur ${slideCount}`;
new Swiper(".dernieres-dynamiques-swiper", {
slidesPerView: 2,
spaceBetween: 30,
loop: true,
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev"
},
pagination: {
el: ".swiper-pagination",
clickable: true,
renderBullet: function (index, className) {
return `<button class="${className}"></button>`;
}
},
on: {
slideChange: swiper => {
const slidesCount = swiper?.slides?.length;
swiperFraction.textContent = `Article n°${swiper.realIndex + 1} sur ${slidesCount}`;
}
}
// pagination: [
// {
// el: ".swiper-pagination",
// type: "bullets",
// clickable: true,
// },
// {
// el: ".swiper-pagination-fraction",
// type: "fraction",
// renderFraction: function (currentClass, totalClass) {
// return (
// '<p class="swiper-pagination__text">' +
// "<span class='swiper-pagination__text-label'>Article n°</span>" +
// '<span class="' +
// currentClass +
// '"></span>' +
// " sur " +
// '<span class="' +
// totalClass +
// '"></span>' +
// "</p>"
// );
// },
// },
// ],
});
});
/******/ })()
;
//# sourceMappingURL=view.js.map