scrollTop not working correctly?

scrollTop not working correctly?

Hi,

 

I am trying to get a scroll function to work without 100% luck.

 

I have a a few links that are position:fixed on my side for easy nav to a particular section. I want it to work so when user clicks it the page with auto scroll to the particular div.

 

e.g

 

div Stage One

div Stage Two

 

and when you click

a Stage One or

a Stage Two

 

the page will scroll down to that div.

 

My problem is when I first click it, it does scroll down but too far, if i try it again though it works fine.

 

The divs that it scrolls to are hidden e.g. display:none and when the link is clicked the div is shown and then should scroll. I think it may have soething to do with the display:none for some reason.

 

Heres my code


$(function() {

  1. $( "#step-install" ).click(function() {

     

              $('html, body').animate({

                        scrollTop: ($('#step2').first().offset().top)

              },500);

     

              $('div#install-content').slideDown("");

              $('div#intro-content').slideUp("");

              $('div#config-content').slideUp("");

    });

    });

as you can see it should scroll and display the hidden div.

 

NOTE: It is scrolling to the div above the hidden one so not sure if it is something to do with the hidden div.

 

Any suggestions.

 

Thanks


Here is a link to my files.

https://www.dropbox.com/sh/7h0w4fbztv7a86e/zXhYHysDOt