I have issue with fixed navigation and scrolling to element position. What this does is, if I click on the link ( anchor ) it scrolls slowly before element as i wish , but then it jumps a few pixels down. Problem is with -> $target.offset().top -50 // if I remove negative value ( -50 ) window scrolls to element but my fixed navigation cover the element little bit but there is no jump... and i if i add negative value window scrolls before element but then it's forced to jump down and I really don't know why....
$(".anchor").each(function () {
$(this).click(function(e) {
e.preventDefault();
var target = this.hash;
$target = $(target);
$('html, body').animate({
scrollTop: $target.offset().top -50
}, 2000, function () {
window.location.hash = target;
});
});
})