Cross-page bookmarks do not scroll to the right position

If I have a link line /page/#bookmark the scrolling behavior works differently in the sydney theme depending on if you are currently on the page or another page. It will scroll down to a different position.

I believe this is because there is javascript in the sydney theme to do slow scrolling when clicking on bookmark anchors to account for the floating header on the top. I believe this javascript needs to be modified to also account for the header onpageload.

This bug wouldn’t show up for a single page website with bookmarks, nor on pages that didn’t use bookmarks. However, websites that mix these two methods will have inconsistency.

To see this in action, follow the following steps:

  1. Visit http://www.tothconstruction.com/
  2. In the “About” menu dropdown, click on “Our Mission”
  3. Once more, In the “About” menu dropdown, click on “Our Mission.” Note when this link is clicked when you’re on the page, the scroll position is different than it was in step 2.

If there is a more appropriate forurm to report a bug, please let me know.

Thanks for your help!

Thanks for the bug report.

Yeah, it’s probably because of the offset we use in the code for the header. We’ll try to handle it for the next theme version.

It’s actually not the offset we use and our smooth scrolling code doesn’t have much to do with this.
Once you click the link in step 3), you’re basically positioned where you’re supposed to be but the menu bar, being sticky, gets on top.

I guess the only way to handle this is to hide the menu bar when the user doesn’t scroll but I’m not sure if this is something we can change at this point without bothering people.

The menu bar is sticky on top as well on step 2, but it positions correctly. If whatever code you have to slow scroll that positions it correctly did so on page load instead of just on link click, it’d fix itself.

Even a single like jquery that onpageload redirected to the same link if it was the same page and it contained a # bookmark in the URL would do it. It would be the same as clicking on the nav after the page loaded.

That’s probably what I’ll do to fix the issue. I was just trying to think of the community and that maybe I wasn’t the only person who had this issue. Did not mean to bother people. I apologize if it’s working the way it was intended.

Things are a bit different when you switch pages. Anyway, try using this in a plugin like TC Custom Javascript:


jQuery(function($) {
	$(document).ready(function() {
		if(window.location.hash) {
			var hash = window.location.hash;
			var $hash = $(hash);
			$('html, body').stop().animate({
				'scrollTop': $hash.offset().top - 70
			}, 100, 'swing');
	    }
	});
});

It can also be changed to load instead of ready in order to have some animations and stuff.
I’m not sure if we’ll add this in the theme.