0

Not I am unsure of how to do what I am asking. Which is why I have decided to appeal to this wonderful community to help me out so I can learn something. Here is my question:

I am making a website that is only going to be one page. Each part of the website such as "About me," "Where am I located," etc are going to be in different locations on the large webpage which you get to by scrolling. Currently I have buttons that bring you to each part of the page with an animation.
Now I am wondering if I can lock scrolling. What I mean by lock scrolling, is if I scroll down, the webpage will automatically take me to the next section without needing to scroll further. Is this possible?
If I am not clear, please let me know and I will try my best to refine my paragraphs.

Thank you guys so much for your time!

Spartan
  • 215
  • 4
  • 11

1 Answers1

0

Yes, it can be achieved by this:

$(window).scroll(function() {
    var winTop = $(this).scrollTop(); // distance frome current top to page top
    if (winTop >= $('#aboutPage').offset().top) { // or you may change to something else
        $('body').animate({
            // animate scrolling to somewhere
            scrollTop: $('#homePage').offset().top
        });
    }
})
Ovilia
  • 7,066
  • 12
  • 47
  • 70
  • Ahh, now I am still new to HTML 5, and especially Java script. What part of the code would I implement that into? – Spartan Feb 09 '13 at 02:03
  • 1
    This is JavaScript code with jQuery library. In this case, it is extremely easier to do with jQuery. If you have no idea, please have a look at `jquery.com`. – Ovilia Feb 09 '13 at 02:10