REFACTOR for better syntax and responsive fix
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
2d2f47c4cc
commit
3c08c72aaf
File diff suppressed because one or more lines are too long
|
|
@ -1 +1 @@
|
|||
<?php return array('dependencies' => array(), 'version' => 'e2a42947538603e62de3');
|
||||
<?php return array('dependencies' => array(), 'version' => 'e4c93dfaede1db21fc16');
|
||||
|
|
|
|||
|
|
@ -2,14 +2,24 @@
|
|||
/*!******************************************!*\
|
||||
!*** ./src/dernieres-dynamiques/view.js ***!
|
||||
\******************************************/
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
function swiperCheckBreakpoints() {
|
||||
const hasSwiper = dernieresDynamiquesSwiper.__swiper__ === true;
|
||||
|
||||
// if (window.innerWidth < 960 && hasSwiper) {
|
||||
// dernieresDynamiquesSwiper.destroy(true, true);
|
||||
// }
|
||||
// if (window.innerWidth >= 960 && !hasSwiper) {
|
||||
// initiateSwiper();
|
||||
// }
|
||||
}
|
||||
function initiateSwiper() {
|
||||
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", {
|
||||
dernieresDynamiquesSwiper = new Swiper(".dernieres-dynamiques-swiper", {
|
||||
slidesPerView: 2,
|
||||
spaceBetween: 30,
|
||||
loop: true,
|
||||
|
|
@ -25,39 +35,30 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||
return `<button class="${className}"></button>`;
|
||||
}
|
||||
},
|
||||
breakpoints: {
|
||||
// when window width is >= 320px
|
||||
|
||||
// when window width is >= 480px
|
||||
320: {
|
||||
slidesPerView: 1
|
||||
},
|
||||
// when window width is >= 640px
|
||||
1100: {
|
||||
slidesPerView: 2
|
||||
}
|
||||
},
|
||||
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>"
|
||||
// );
|
||||
// },
|
||||
// },
|
||||
// ],
|
||||
});
|
||||
}
|
||||
window.addEventListener("DOMContentLoaded", event => {
|
||||
initiateSwiper();
|
||||
swiperCheckBreakpoints();
|
||||
window.addEventListener("resize", swiperCheckBreakpoints);
|
||||
});
|
||||
/******/ })()
|
||||
;
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
{"version":3,"file":"dernieres-dynamiques/view.js","mappings":";;;;AAAAA,QAAQ,CAACC,gBAAgB,CAAC,kBAAkB,EAAE,YAAY;EACzD,MAAMC,YAAY,GAAGF,QAAQ,CAACG,aAAa,CAAC,6BAA6B,CAAC;EAC1E,IAAI,CAACD,YAAY,EAAE;EAEnB,MAAME,cAAc,GAAGF,YAAY,CAACC,aAAa,CAChD,6BACD,CAAC;EACD,MAAME,MAAM,GAAGH,YAAY,CAACI,gBAAgB,CAAC,eAAe,CAAC;EAC7D,MAAMC,UAAU,GAAGF,MAAM,CAACG,MAAM;EAChCJ,cAAc,CAACK,WAAW,GAAG,mBAAmBF,UAAU,EAAE;EAE5D,IAAIG,MAAM,CAAC,8BAA8B,EAAE;IAC1CC,aAAa,EAAE,CAAC;IAChBC,YAAY,EAAE,EAAE;IAChBC,IAAI,EAAE,IAAI;IACVC,UAAU,EAAE,IAAI;IAChBC,UAAU,EAAE;MACXC,MAAM,EAAE,qBAAqB;MAC7BC,MAAM,EAAE;IACT,CAAC;IACDC,UAAU,EAAE;MACXC,EAAE,EAAE,oBAAoB;MACxBC,SAAS,EAAE,IAAI;MACfC,YAAY,EAAE,SAAAA,CAAUC,KAAK,EAAEC,SAAS,EAAE;QACzC,OAAO,kBAAkBA,SAAS,aAAa;MAChD;IACD,CAAC;IACDC,EAAE,EAAE;MACHC,WAAW,EAAGC,MAAM,IAAK;QACxB,MAAMC,WAAW,GAAGD,MAAM,EAAErB,MAAM,EAAEG,MAAM;QAC1CJ,cAAc,CAACK,WAAW,GAAG,aAC5BiB,MAAM,CAACE,SAAS,GAAG,CAAC,QACbD,WAAW,EAAE;MACtB;IACD;;IAEA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACA;EACD,CAAC,CAAC;AACH,CAAC,CAAC,C","sources":["webpack://dernieres-dynamiques/./src/dernieres-dynamiques/view.js"],"sourcesContent":["document.addEventListener(\"DOMContentLoaded\", function () {\n\tconst currentBlock = document.querySelector(\".block-dernieres-dynamiques\");\n\tif (!currentBlock) return;\n\n\tconst swiperFraction = currentBlock.querySelector(\n\t\t\".swiper-pagination-fraction\"\n\t);\n\tconst slides = currentBlock.querySelectorAll(\".swiper-slide\");\n\tconst slideCount = slides.length;\n\tswiperFraction.textContent = `Article n°1 sur ${slideCount}`;\n\n\tnew Swiper(\".dernieres-dynamiques-swiper\", {\n\t\tslidesPerView: 2,\n\t\tspaceBetween: 30,\n\t\tloop: true,\n\t\tgrabCursor: true,\n\t\tnavigation: {\n\t\t\tnextEl: \".swiper-button-next\",\n\t\t\tprevEl: \".swiper-button-prev\",\n\t\t},\n\t\tpagination: {\n\t\t\tel: \".swiper-pagination\",\n\t\t\tclickable: true,\n\t\t\trenderBullet: function (index, className) {\n\t\t\t\treturn `<button class=\"${className}\"></button>`;\n\t\t\t},\n\t\t},\n\t\ton: {\n\t\t\tslideChange: (swiper) => {\n\t\t\t\tconst slidesCount = swiper?.slides?.length;\n\t\t\t\tswiperFraction.textContent = `Article n°${\n\t\t\t\t\tswiper.realIndex + 1\n\t\t\t\t} sur ${slidesCount}`;\n\t\t\t},\n\t\t},\n\n\t\t// pagination: [\n\t\t// \t{\n\t\t// \t\tel: \".swiper-pagination\",\n\t\t// \t\ttype: \"bullets\",\n\t\t// \t\tclickable: true,\n\t\t// \t},\n\t\t// \t{\n\t\t// \t\tel: \".swiper-pagination-fraction\",\n\t\t// \t\ttype: \"fraction\",\n\t\t// \t\trenderFraction: function (currentClass, totalClass) {\n\t\t// \t\t\treturn (\n\t\t// \t\t\t\t'<p class=\"swiper-pagination__text\">' +\n\t\t// \t\t\t\t\"<span class='swiper-pagination__text-label'>Article n°</span>\" +\n\t\t// \t\t\t\t'<span class=\"' +\n\t\t// \t\t\t\tcurrentClass +\n\t\t// \t\t\t\t'\"></span>' +\n\t\t// \t\t\t\t\" sur \" +\n\t\t// \t\t\t\t'<span class=\"' +\n\t\t// \t\t\t\ttotalClass +\n\t\t// \t\t\t\t'\"></span>' +\n\t\t// \t\t\t\t\"</p>\"\n\t\t// \t\t\t);\n\t\t// \t\t},\n\t\t// \t},\n\t\t// ],\n\t});\n});\n"],"names":["document","addEventListener","currentBlock","querySelector","swiperFraction","slides","querySelectorAll","slideCount","length","textContent","Swiper","slidesPerView","spaceBetween","loop","grabCursor","navigation","nextEl","prevEl","pagination","el","clickable","renderBullet","index","className","on","slideChange","swiper","slidesCount","realIndex"],"sourceRoot":""}
|
||||
{"version":3,"file":"dernieres-dynamiques/view.js","mappings":";;;;AAAA,SAASA,sBAAsBA,CAAA,EAAG;EACjC,MAAMC,SAAS,GAAGC,yBAAyB,CAACC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B,EAAGC,KAAK,IAAK;EACtDhC,cAAc,CAAC,CAAC;EAChBJ,sBAAsB,CAAC,CAAC;EAExBkC,MAAM,CAACC,gBAAgB,CAAC,QAAQ,EAAEnC,sBAAsB,CAAC;AAC1D,CAAC,CAAC,C","sources":["webpack://dernieres-dynamiques/./src/dernieres-dynamiques/view.js"],"sourcesContent":["function swiperCheckBreakpoints() {\n\tconst hasSwiper = dernieresDynamiquesSwiper.__swiper__ === true;\n\n\t// if (window.innerWidth < 960 && hasSwiper) {\n\t// \tdernieresDynamiquesSwiper.destroy(true, true);\n\t// }\n\t// if (window.innerWidth >= 960 && !hasSwiper) {\n\t// \tinitiateSwiper();\n\t// }\n}\n\nfunction initiateSwiper() {\n\tconst currentBlock = document.querySelector(\".block-dernieres-dynamiques\");\n\tif (!currentBlock) return;\n\n\tconst swiperFraction = currentBlock.querySelector(\n\t\t\".swiper-pagination-fraction\"\n\t);\n\tconst slides = currentBlock.querySelectorAll(\".swiper-slide\");\n\tconst slideCount = slides.length;\n\tswiperFraction.textContent = `Article n°1 sur ${slideCount}`;\n\n\tdernieresDynamiquesSwiper = new Swiper(\".dernieres-dynamiques-swiper\", {\n\t\tslidesPerView: 2,\n\t\tspaceBetween: 30,\n\t\tloop: true,\n\t\tgrabCursor: true,\n\t\tnavigation: {\n\t\t\tnextEl: \".swiper-button-next\",\n\t\t\tprevEl: \".swiper-button-prev\",\n\t\t},\n\t\tpagination: {\n\t\t\tel: \".swiper-pagination\",\n\t\t\tclickable: true,\n\t\t\trenderBullet: function (index, className) {\n\t\t\t\treturn `<button class=\"${className}\"></button>`;\n\t\t\t},\n\t\t},\n\t\tbreakpoints: {\n\t\t\t// when window width is >= 320px\n\n\t\t\t// when window width is >= 480px\n\t\t\t320: {\n\t\t\t\tslidesPerView: 1,\n\t\t\t},\n\t\t\t// when window width is >= 640px\n\t\t\t1100: {\n\t\t\t\tslidesPerView: 2,\n\t\t\t},\n\t\t},\n\t\ton: {\n\t\t\tslideChange: (swiper) => {\n\t\t\t\tconst slidesCount = swiper?.slides?.length;\n\t\t\t\tswiperFraction.textContent = `Article n°${\n\t\t\t\t\tswiper.realIndex + 1\n\t\t\t\t} sur ${slidesCount}`;\n\t\t\t},\n\t\t},\n\t});\n}\n\nwindow.addEventListener(\"DOMContentLoaded\", (event) => {\n\tinitiateSwiper();\n\tswiperCheckBreakpoints();\n\n\twindow.addEventListener(\"resize\", swiperCheckBreakpoints);\n});\n"],"names":["swiperCheckBreakpoints","hasSwiper","dernieresDynamiquesSwiper","__swiper__","initiateSwiper","currentBlock","document","querySelector","swiperFraction","slides","querySelectorAll","slideCount","length","textContent","Swiper","slidesPerView","spaceBetween","loop","grabCursor","navigation","nextEl","prevEl","pagination","el","clickable","renderBullet","index","className","breakpoints","on","slideChange","swiper","slidesCount","realIndex","window","addEventListener","event"],"sourceRoot":""}
|
||||
|
|
@ -1,4 +1,15 @@
|
|||
document.addEventListener("DOMContentLoaded", function () {
|
||||
function swiperCheckBreakpoints() {
|
||||
const hasSwiper = dernieresDynamiquesSwiper.__swiper__ === true;
|
||||
|
||||
// if (window.innerWidth < 960 && hasSwiper) {
|
||||
// dernieresDynamiquesSwiper.destroy(true, true);
|
||||
// }
|
||||
// if (window.innerWidth >= 960 && !hasSwiper) {
|
||||
// initiateSwiper();
|
||||
// }
|
||||
}
|
||||
|
||||
function initiateSwiper() {
|
||||
const currentBlock = document.querySelector(".block-dernieres-dynamiques");
|
||||
if (!currentBlock) return;
|
||||
|
||||
|
|
@ -9,7 +20,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||
const slideCount = slides.length;
|
||||
swiperFraction.textContent = `Article n°1 sur ${slideCount}`;
|
||||
|
||||
new Swiper(".dernieres-dynamiques-swiper", {
|
||||
dernieresDynamiquesSwiper = new Swiper(".dernieres-dynamiques-swiper", {
|
||||
slidesPerView: 2,
|
||||
spaceBetween: 30,
|
||||
loop: true,
|
||||
|
|
@ -25,6 +36,18 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||
return `<button class="${className}"></button>`;
|
||||
},
|
||||
},
|
||||
breakpoints: {
|
||||
// when window width is >= 320px
|
||||
|
||||
// when window width is >= 480px
|
||||
320: {
|
||||
slidesPerView: 1,
|
||||
},
|
||||
// when window width is >= 640px
|
||||
1100: {
|
||||
slidesPerView: 2,
|
||||
},
|
||||
},
|
||||
on: {
|
||||
slideChange: (swiper) => {
|
||||
const slidesCount = swiper?.slides?.length;
|
||||
|
|
@ -33,31 +56,12 @@ document.addEventListener("DOMContentLoaded", function () {
|
|||
} 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>"
|
||||
// );
|
||||
// },
|
||||
// },
|
||||
// ],
|
||||
});
|
||||
}
|
||||
|
||||
window.addEventListener("DOMContentLoaded", (event) => {
|
||||
initiateSwiper();
|
||||
swiperCheckBreakpoints();
|
||||
|
||||
window.addEventListener("resize", swiperCheckBreakpoints);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user