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

183
Visualizações
How scroll trigger move to next block function?

Why when I scroll, the window can't scroll to the next block? Does it cause from scrollTop: '#' + $('.is-current').next().attr('id')? Also I have tried use offset().top to get the position, but it didn't work.

$('.scroll-block:first').addClass('is-current');
$(window).on('mouseover', function(event) {
  if ($('.scroll-block').hasClass('is-current')) {
    $('.scroll-block').removeClass('is-current');
    $(event.target).parents('.scroll-block:first').addClass('is-current');
  } else {
    $(event.target).parents('.scroll-block:first').addClass('is-current');
  };
});

$(window).on('scroll', function() {
  var scroll = $(window).scrollTop();
  var position;
  $('.is-current').each(function() {
    position = $(this);
    console.log(scroll)
    $('html').animate({
      scrollTop: position.next().offset().top
    }, 800)
    console.log($(this).next().offset().top)
  });
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<div class="scroll-block container" id="block1"></div>
<div class="scroll-block container" id="block2"></div>
<div class="scroll-block container" id="block3"></div>
<div class="scroll-block container" id="block4"></div>

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

use CSS scroll-snap-type: y mandatory to "locking" the position of the viewport to specific elements on the page as the window.

scroll-snap-type

about 4 years ago · Juan Pablo Isaza Relatório
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