Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

265
Visualizações
Swiper.js with lazy image loading initiating at the wrong height on mobile

I have updated my website to have lazy loading images with swiper.js.

When the page loads and swiper is initiated, swiper sets the height of the div containing the slides wrong. Its briefly sets the height to 460px which is the hieght on desktop. When the images are loaded the height is then updated to 186px which is correct for mobile.

I only noticed this after lazy loading was setup.

How can I stop swiper initiating at the wrong size?

This is what it looks like briefly for a second. Example

The slide image is prefilled with a placeholder image, width 1200px, height 460px. Then CSS setting the image to width 100% and height auto;

This is my script.

    const myswiperban = new Swiper('.swiper-container-ban-wide', {
            loop: true,
            pagination: {
                el: '.swiper-pagination-ban-wide',
                clickable: true
            },
            navigation: {
                nextEl: '.swiper-button-next-ban-wide',
                prevEl: '.swiper-button-prev-ban-wide',
            },
            slidesPerView:1,
            freeMode:true,
            autoplay: {
                delay: 3000
            },
            autoHeight:true,
            preloadImages: false,
            lazy: {
                loadPrevNext: true
            },
    });

Any ideas?

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda