Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

189
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda