Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

181
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!