From 29437e281ad0f13332dd83bfd897a78aa7d993ee Mon Sep 17 00:00:00 2001 From: Valentin Date: Sun, 21 Apr 2024 18:54:00 +0200 Subject: [PATCH] toutes les images ne sont pas resize 4 --- user/themes/ateliers-55/js/script.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/user/themes/ateliers-55/js/script.js b/user/themes/ateliers-55/js/script.js index 214ade6..d2660da 100644 --- a/user/themes/ateliers-55/js/script.js +++ b/user/themes/ateliers-55/js/script.js @@ -70,14 +70,12 @@ function initSwiper() { } function resizeVerticalImages() { - setTimeout(() => { - let verticalImages = document.querySelectorAll('.swiper-slide > img'); - for (let img of verticalImages) { - console.log(img.clientHeight > img.clientWidth); + let verticalImages = document.querySelectorAll('.swiper-slide > img'); + for (let img of verticalImages) { + img.addEventListener('load', () => { if (img.clientHeight > img.clientWidth) { - console.log("yes"); img.style.width = "50%"; } - } - }, 200); + }) + } } \ No newline at end of file