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

147
Visualizações
Scroll to not letting page move

I am trying to trigger scroll when the user reach a specific div , however after scrolling to div, it is not letting the page to go either up or down. Kind of stucked. Any way to prevent this behaviour so that it only triggers when the user is scrolling from top.

jQuery(window).scroll(function() {
  var hT = jQuery('.trigegr').offset().top,
    hH = jQuery('.trigegr').outerHeight(),
    wH = jQuery(window).height(),
    wS = jQuery(this).scrollTop();
  if (wS > (hT + hH - wH)) {
    jQuery('html, body').animate({
      scrollTop: jQuery("#scroll-too").offset().top
    }, 2000);
  }
});
div {
  height: 800px;
  background: red;
}

h1 {
  display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div>Scroll Down</div>
<h1 class="trigegr">I am The H1</h1>

<br><br><br><br><br><br>
<h2 id="scroll-too">I am The H2</h2>

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