toutes les images ne sont pas resize 6
This commit is contained in:
parent
92b77e0ad1
commit
f6934de1ef
|
@ -73,17 +73,31 @@ function resizeVerticalImages() {
|
||||||
let verticalImages = document.querySelectorAll('.swiper-slide > img');
|
let verticalImages = document.querySelectorAll('.swiper-slide > img');
|
||||||
let imagesIndex = 0;
|
let imagesIndex = 0;
|
||||||
for (let img of verticalImages) {
|
for (let img of verticalImages) {
|
||||||
imagesIndex++;
|
if(img.complete){
|
||||||
img.addEventListener('load', () => {
|
imagesIndex++;
|
||||||
if (img.clientHeight > img.clientWidth) {
|
if (img.clientHeight > img.clientWidth) {
|
||||||
img.style.width = "50%";
|
img.style.width = "50%";
|
||||||
}
|
}
|
||||||
})
|
if (imagesIndex === verticalImages.length) {
|
||||||
if (imagesIndex === verticalImages.length) {
|
swiperSlideEls = document.querySelectorAll('.swiper-slide');
|
||||||
swiperSlideEls = document.querySelectorAll('.swiper-slide');
|
for (let swiperSlideEl of swiperSlideEls) {
|
||||||
for (let swiperSlideEl of swiperSlideEls) {
|
swiperSlideEl.style.maxHeight = "unset";
|
||||||
swiperSlideEl.style.maxHeight = "unset";
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
img.onload = () => {
|
||||||
|
imagesIndex++;
|
||||||
|
if (img.clientHeight > img.clientWidth) {
|
||||||
|
img.style.width = "50%";
|
||||||
|
}
|
||||||
|
if (imagesIndex === verticalImages.length) {
|
||||||
|
swiperSlideEls = document.querySelectorAll('.swiper-slide');
|
||||||
|
for (let swiperSlideEl of swiperSlideEls) {
|
||||||
|
swiperSlideEl.style.maxHeight = "unset";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue