From 44301d5fd46b0791689531abd858bf01abb7f0c2 Mon Sep 17 00:00:00 2001 From: Valentin Date: Sun, 21 Apr 2024 18:48:08 +0200 Subject: [PATCH] toutes les images ne sont pas resize 2 --- user/themes/ateliers-55/js/script.js | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/user/themes/ateliers-55/js/script.js b/user/themes/ateliers-55/js/script.js index 40e48a1..bdb2193 100644 --- a/user/themes/ateliers-55/js/script.js +++ b/user/themes/ateliers-55/js/script.js @@ -21,9 +21,7 @@ $(document).ready(function() { let swiperEl = document.querySelector('.swiper'); if (swiperEl) { swiperEl.style.opacity = 1; - setTimeout(() => { - resizeVerticalImages(); - }, 100); + resizeVerticalImages(); } initSwiper(); barba.init({ @@ -57,11 +55,8 @@ $(document).ready(function() { } else { body.style.overflowY = "auto"; } - setTimeout(() => { - resizeVerticalImages(); - }, 100); + resizeVerticalImages(); }); - }) function initSwiper() { @@ -75,12 +70,12 @@ function initSwiper() { } function resizeVerticalImages() { - if (document.querySelector('.swiper')) { - let verticalImages = document.querySelectorAll('.swiper-slide > img'); - for (let img of verticalImages) { - if (img.clientHeight > img.clientWidth) { - img.style.width = "50%"; - } + let verticalImages = document.querySelectorAll('.swiper-slide > img'); + for (let img of verticalImages) { + console.log(img.clientHeight > img.clientWidth); + if (img.clientHeight > img.clientWidth) { + console.log("yes"); + img.style.width = "50%"; } } } \ No newline at end of file