I have a one-page site that will follow the following pattern:
<section id="home"></section>
<section id="empresa"></section>
<section id="mapa"></section>
<section id="contato"></section>
For transitioning screens, I usually use scrollTop
, however I have to report the position of each section in px
. And that's not what I want.
Is there any way I can scroll directly to the desired id , or something like that?
What I currently use:
$('.home').click(function () {
$('html, body').stop().animate({
scrollTop: '0'
}, 700);
setHistory('MEUSITE- Home', site + '/home');
});
$('.empresa').click(function () {
$('html, body').stop().animate({
scrollTop: '855px'
}, 700);
setHistory('MEUSITE- Empresa', site + '/empresa');
});