Ive got this rather popular code:
jQuery(document).ready(function($) {
$(".scroll").click(function(event){
event.preventDefault();
$('html,body').animate({scrollTop:$(this.hash).offset().top}, 500);
});
});
And in html:
<a href="#scrollThere">Click</a>
Goes to
<div class="scroll" id="scrollThere"></div>
But on one page website when the divs are on different height, i.e. The scroll has to go on different lenghths - the scrolling is sometimes much faster and sometimes very slow. What kind of code would make te scroll always be time = speed * distance, not time = lentgh in ms or in other words how can I achieve always the same speed?