html - jquery scrollTop offset issue -
i trying build anchor link allows panel 2 slide cover panel 1, leave black header visible:
i'm setting offset with:
'scrolltop': $target.offset().top - 140
it milisecond , jump top of page.
how can set stops in right place?
it works have written:
$('html, body').stop().animate({ 'scrolltop': $target.offset().top - 140 }, 600, 'swing', function () { window.location.hash = target; });
the first part animates scrolling, , when finished, tell window jump specific hash.
notice happens when click function has this:
window.location.hash = target;
remove callback function , prevent page jumping hash.
on unrelated note, suggest don't use hard-coded values in animation function. try instead:
'scrolltop': $target.offset().top - $("#a").offset().top;
Comments
Post a Comment