May 17, 2016
Can bet setup to occur automatically onload. If there is a large menu section that you’d like visitors to scroll past on subpages.
Original (sourced here):
$('html, body').stop().animate({ 'scrollTop': $target.offset().top + (-40) }, 900, 'swing', function () { window.location.hash = target; });
Adjusted for page specific loading:
jQuery(document).ready(function(){ REL.init(); }); var REL = {}; REL.init = function() { if (jQuery('.page-child').length > 0) { REL.signpost_scroll(); } else if (jQuery('.blog').length > 0 ) { REL.signpost_scroll(); } } REL.signpost_scroll = function() { jQuery('html, body').stop().animate({ 'scrollTop': jQuery('#target').offset().top + (-40) }, 900, 'swing', function () { window.location.hash = jQuery('#target'); }); }