Ok, I managed to make it work with your advice, but i still have slight problem. After entering page from external link, page is loaded on desired anchor, then it jumps to top and then it scrolls back to said anchor.
Idk how to recreate this for you in codepen because it needs to be open from external link. Here is the piece of code I'm using:
$(function(){
var wrapper = $("#wrapper"),
$menu = $("#navLinks"),
$window = $(window);
$menu.on("click","a", function(){
var $this = $(this),
href = $this.attr("href"),
topY = $(href).offset().top;
TweenMax.to($window, 2, {scrollTo: {y: topY, offsetY: 50, autoKill: true}, ease:Power4.easeInOut});
return false;
});
setTimeout( function() {
if( location.hash && $(location.hash).length > 0 ) {
window.scrollTo(0,0);
TweenMax.to($(window), 2, {scrollTo: {y: $(location.hash), offsetY: 50, autoKill: true}, ease:Power4.easeInOut});
}
});
});
I can give you link to the live project if you want to see the said behavior.
Again, thank you for your time and help, i really appreciate if.