Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript

smooth auto scroll based on pixels scrolled

im trying to have several small dots that represent the current section of the site your on.....the problem is i cant use anchors bc all of my elements are fixed and the layout doesnt work with it....so i need to be able to click on the button....and have it scroll to 800px...the second button scrolls to 1200 px etc....i am currently using this script for a complete page scroll but it only allows me to use anchors to scroll to....it works for the full page scroll but not my other situations

        $('html, body').animate({
        scrollTop: $(".over").offset().top
    },12000);


i need a pixel based scroll

1 Answer

nevermind...i got it

$(".scroll").click(function(event){
    $('html, body').animate({scrollTop: '+=1080px'}, 800);
});