toutes les images ne sont pas resize 2

This commit is contained in:
Valentin 2024-04-21 18:48:08 +02:00
parent 25a022ea48
commit 44301d5fd4
1 changed files with 8 additions and 13 deletions

View File

@ -21,9 +21,7 @@ $(document).ready(function() {
let swiperEl = document.querySelector('.swiper'); let swiperEl = document.querySelector('.swiper');
if (swiperEl) { if (swiperEl) {
swiperEl.style.opacity = 1; swiperEl.style.opacity = 1;
setTimeout(() => {
resizeVerticalImages(); resizeVerticalImages();
}, 100);
} }
initSwiper(); initSwiper();
barba.init({ barba.init({
@ -57,11 +55,8 @@ $(document).ready(function() {
} else { } else {
body.style.overflowY = "auto"; body.style.overflowY = "auto";
} }
setTimeout(() => {
resizeVerticalImages(); resizeVerticalImages();
}, 100);
}); });
}) })
function initSwiper() { function initSwiper() {
@ -75,12 +70,12 @@ function initSwiper() {
} }
function resizeVerticalImages() { function resizeVerticalImages() {
if (document.querySelector('.swiper')) {
let verticalImages = document.querySelectorAll('.swiper-slide > img'); let verticalImages = document.querySelectorAll('.swiper-slide > img');
for (let img of verticalImages) { for (let img of verticalImages) {
console.log(img.clientHeight > img.clientWidth);
if (img.clientHeight > img.clientWidth) { if (img.clientHeight > img.clientWidth) {
console.log("yes");
img.style.width = "50%"; img.style.width = "50%";
} }
} }
}
} }