FEATURE Enanching swiper behaviour
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Antoine M 2025-09-16 14:04:38 +02:00
parent f36861f9da
commit 5e8b6615b0
4 changed files with 24 additions and 2 deletions

View File

@ -1 +1 @@
<?php return array('dependencies' => array(), 'version' => 'e4c93dfaede1db21fc16');
<?php return array('dependencies' => array(), 'version' => 'cb2dd53a3faeb0a76aff');

View File

@ -24,10 +24,22 @@ function initiateSwiper() {
spaceBetween: 30,
loop: true,
grabCursor: true,
keyboard: {
enabled: true,
onlyInViewport: true
},
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev"
},
mousewheel: {
enabled: true,
forceToAxis: true,
// Force le scroll dans l'axe du slider
sensitivity: 1,
// Sensibilité du scroll (1 = normal)
releaseOnEdges: false // Continue le scroll même aux bords
},
pagination: {
el: ".swiper-pagination",
clickable: true,

View File

@ -1 +1 @@
{"version":3,"file":"dernieres-dynamiques/view.js","mappings":";;;;AAAA,SAASA,sBAAsBA,CAAA,EAAG;EACjC,MAAMC,SAAS,GAAGC,yBAAyB,CAACC,UAAU,KAAK,IAAI;;EAE/D;EACA;EACA;EACA;EACA;EACA;AACD;AAEA,SAASC,cAAcA,CAAA,EAAG;EACzB,MAAMC,YAAY,GAAGC,QAAQ,CAACC,aAAa,CAAC,6BAA6B,CAAC;EAC1E,IAAI,CAACF,YAAY,EAAE;EAEnB,MAAMG,cAAc,GAAGH,YAAY,CAACE,aAAa,CAChD,6BACD,CAAC;EACD,MAAME,MAAM,GAAGJ,YAAY,CAACK,gBAAgB,CAAC,eAAe,CAAC;EAC7D,MAAMC,UAAU,GAAGF,MAAM,CAACG,MAAM;EAChCJ,cAAc,CAACK,WAAW,GAAG,mBAAmBF,UAAU,EAAE;EAE5DT,yBAAyB,GAAG,IAAIY,MAAM,CAAC,8BAA8B,EAAE;IACtEC,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,WAAW,EAAE;MACZ;;MAEA;MACA,GAAG,EAAE;QACJb,aAAa,EAAE;MAChB,CAAC;MACD;MACA,IAAI,EAAE;QACLA,aAAa,EAAE;MAChB;IACD,CAAC;IACDc,EAAE,EAAE;MACHC,WAAW,EAAGC,MAAM,IAAK;QACxB,MAAMC,WAAW,GAAGD,MAAM,EAAEtB,MAAM,EAAEG,MAAM;QAC1CJ,cAAc,CAACK,WAAW,GAAG,aAC5BkB,MAAM,CAACE,SAAS,GAAG,CAAC,QACbD,WAAW,EAAE;MACtB;IACD;EACD,CAAC,CAAC;AACH;AAEAE,MAAM,CAACC,gBAAgB,CAAC,kBAAkB,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":""}
{"version":3,"file":"dernieres-dynamiques/view.js","mappings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AAa,EAAE;MAChB;IACD,CAAC;IACDqB,EAAE,EAAE;MACHC,WAAW,EAAGC,MAAM,IAAK;QACxB,MAAMC,WAAW,GAAGD,MAAM,EAAE7B,MAAM,EAAEG,MAAM;QAC1CJ,cAAc,CAACK,WAAW,GAAG,aAC5ByB,MAAM,CAACE,SAAS,GAAG,CAAC,QACbD,WAAW,EAAE;MACtB;IACD;EACD,CAAC,CAAC;AACH;AAEAE,MAAM,CAACC,gBAAgB,CAAC,kBAAkB,EAAGC,KAAK,IAAK;EACtDvC,cAAc,CAAC,CAAC;EAChBJ,sBAAsB,CAAC,CAAC;EAExByC,MAAM,CAACC,gBAAgB,CAAC,QAAQ,EAAE1C,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\tkeyboard: {\n\t\t\tenabled: true,\n\t\t\tonlyInViewport: true,\n\t\t},\n\t\tnavigation: {\n\t\t\tnextEl: \".swiper-button-next\",\n\t\t\tprevEl: \".swiper-button-prev\",\n\t\t},\n\t\tmousewheel: {\n\t\t\tenabled: true,\n\t\t\tforceToAxis: true, // Force le scroll dans l'axe du slider\n\t\t\tsensitivity: 1, // Sensibilité du scroll (1 = normal)\n\t\t\treleaseOnEdges: false, // Continue le scroll même aux bords\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","keyboard","enabled","onlyInViewport","navigation","nextEl","prevEl","mousewheel","forceToAxis","sensitivity","releaseOnEdges","pagination","el","clickable","renderBullet","index","className","breakpoints","on","slideChange","swiper","slidesCount","realIndex","window","addEventListener","event"],"sourceRoot":""}

View File

@ -25,10 +25,20 @@ function initiateSwiper() {
spaceBetween: 30,
loop: true,
grabCursor: true,
keyboard: {
enabled: true,
onlyInViewport: true,
},
navigation: {
nextEl: ".swiper-button-next",
prevEl: ".swiper-button-prev",
},
mousewheel: {
enabled: true,
forceToAxis: true, // Force le scroll dans l'axe du slider
sensitivity: 1, // Sensibilité du scroll (1 = normal)
releaseOnEdges: false, // Continue le scroll même aux bords
},
pagination: {
el: ".swiper-pagination",
clickable: true,