Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8658995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:53:55+00:00 2026-06-12T15:53:55+00:00

I have a page that I’m building and I would like to make it

  • 0

I have a page that I’m building and I would like to make it that when I scroll (up or down) the page scrolls to the next div (each div is 100% the height of the window). And gets “fixed” there until you scroll again. An example of what I’m trying to accomplish can be seen here:

http://testdays.hondamoto.ch/

You will notice that when you scroll down, it automatically moves you to the next “div”.

What I’ve tried:

  • Using the jQuery .scroll event combined with:

        function updatePosition() {
          if(canScroll) {
            var pageName;
            canScroll = false;
            var st = $(window).scrollTop();
            if (st > lastScrollTop){
               // downscroll code
               if(pageNumber < 7) {
                   pageNumber++;
               }
               pageName = '#' + getPageToScrollTo().id;
               $('body').animate({ scrollTop: $(pageName).offset().top }, 2000, function() {
                   canScroll = true;
               });
            } else {
              // upscroll code
              if(pageNumber > 0) {
                  pageNumber--;
              }
              pageName = '#' + getPageToScrollTo().id;
              $('body').animate({ scrollTop: $(pageName).offset().top }, 2000, function() {
                   canScroll = true;
                });
            }
            lastScrollTop = st;
          }
        }
    

But the scroll event was getting called when the page was scrolling (animating), AND when the user scrolled. I only need it to be called when the user scrolls.

Then I added:

var throttled = _.throttle(updatePosition, 3000);

$(document).scroll(throttled);

From the Underscore.js library – but it still did the same.

Finally, I browsed here a bit and found:

Call Scroll only when user scrolls, not when animate()

But I was unable to implement that solution. Is there anyone that knows of any libraries or methods to get this working?

EDIT:
Solution based on Basic’s answer:

  function nextPage() {
        canScroll = false;
        if(pageNumber < 7) {
            pageNumber++;
        }
        pageName = getPageToScrollTo();
        $('html, body').stop().animate({ scrollTop: $(pageName).offset().top }, 1000, function() {
            canScroll = true;
        });
    }

    function prevPage() {
        canScroll = false;
        if(pageNumber > 0) {
        pageNumber--;
      }
      pageName = getPageToScrollTo();
      $('html, body').stop().animate({ scrollTop: $(pageName).offset().top }, 1000, function() {
         canScroll = true;
      });
    }

    //--Bind mouseWheel
    $(window).on(mousewheelevt, function(event) {
        event.preventDefault();
        if(canScroll){
          if(mousewheelevt == "mousewheel") {
              if (event.originalEvent.wheelDelta >= 0) {
                prevPage();
              } else {
                nextPage();
              }
          } else if(mousewheelevt == "DOMMouseScroll") {
              if (event.originalEvent.detail >= 0) {
                nextPage();
              } else {
                prevPage();
              }
          }
        }
    });
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:53:56+00:00Added an answer on June 12, 2026 at 3:53 pm

    Ok…

    The relevant code for the Honda site can be found in http://testdays.hondamoto.ch/js/script_2.js. It seems to be doing some calculations to locate the top of the div then scroll to it. There are handlers for different types of scrolling.

    Specifically, the movement is handled by function navigation(target)

    the key bits is here…

    $('html,body').stop().animate({
            scrollTop: $(target).offset().top + newMargin
        }, 1000,'easeInOutExpo',function(){
            //Lots of "page"-specific stuff
        }
    });
    

    There are handlers for the scroll types…

    $('body').bind('touchstart', function(event) {
        //if(currentNav!=3){
            // jQuery clones events, but only with a limited number of properties for perf reasons. Need the original event to get 'touches'
            var e = event.originalEvent;
            scrollStartPos = e.touches[0].pageY;
        //}
    });
    
    //--Bind mouseWheel
    $('*').bind('mousewheel', function(event, delta) {
        event.preventDefault();
        //trace('class : '+$(this).attr('class') + '   id : '+$(this).attr('id'));
        if(!busy && !lockScrollModel && !lockScrollMap){
            if(delta<0){
                nextPage();
            }else{
                prevPage();
            }
        }
    });
    

    You’ll note that the navigate() function sets a busy flag which is unset when scrolling completes – which is how it suppresses all new scroll events during a scroll. Try changing the direction of scroll while the page is already scrolling and you’ll notice user input is being ignored too.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a page that I would like to password protect. This page should
I have a page that consists of a header div for navigation, a content
I have a page that has no vertical scroll, rather, everything is displayed horizontally.
I have a page that looks like this: Head and body tags... <form runat=server>
I have a page that shows information from my database. Each array has an
I have page that possibly calls this line. jQuery.ajaxSetup({async:false}) In another function I would
I have a page that is exhibiting the strangest behavior. When building/debugging my project
I have a page that will need to generate thumbnail images for each article.
I have a page that shows times on it like this: 10:00am . I
I have a page that look like this. <html> <head> <title>Welcome</title> </head> <body bgcolor=white

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.