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

80
Visualizações
Bi-Directional Infinite Scroll Loop

I'm currently using code from this question and this fiddle to achieve a bi-directional infinite scroll loop for a page of vertically scrolling images. This is working fine, however when the browser window is rescaled it breaks. How would I make it responsive? Also maybe there is a better way to approach this altogether now?

var bgHeight = 1970; // pixel height of background image

$(document).ready(function() {
  $('body').height(bgHeight + $(window).height());
  $(window).scroll(function() {
    if ($(window).scrollTop() >= ($('body').height() - $(window).height())) {
      $(window).scrollTop(1);
    } else if ($(window).scrollTop() == 0) {
      $(window).scrollTop($('body').height() - $(window).height() - 1);
    }
  });
});

$(window).resize(function() {
  $('body').height(bgHeight + $(window).height());
});
html,
body {
  height: 100%;
  overflow-x: none;
}

body {
  background-color: white;
  color: black;
  font-family: DecimaMono;
  font-size: 1rem;
  line-height: 1.85;
  height: 1970;
  width: 100vw;
  padding: 20px 20px;
  opacity: 100%;
  -moz-transition: all .15s ease-in;
  -o-transition: all .15s ease-in;
  -webkit-transition: all .15s ease-in;
  transition: all .15s ease-in;
}

img {
  max-width: 100%;
  max-height: 80vh;
  display: block;
  padding: 80px;
  background-color: #CCC; /* just for this demo */
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<div class="grid-3">
  <img src="assets/Clints/Clints-3.jpg" alt="" />
  <img src="assets/Clints/Clints-1.jpg" alt="" />
  <img src="assets/Clints/Clints-2.jpg" alt="" />
  <img src="assets/Clints/Clints-3.jpg" alt="" />
  <img src="assets/Clints/Clints-1.jpg" alt="" />
</div>

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