Skip to content
This repository has been archived by the owner on Jan 24, 2018. It is now read-only.

Page is loading at the top of the window. Hash URLs rendered useless when going to links. Help! #32

Open
sdawson26 opened this issue Jan 5, 2014 · 9 comments

Comments

@sdawson26
Copy link

If I'm on the root page "/" and click an anchor such as "/#link", the skrollr takes me there just fine. However, when I go to the actual /#link URL, it jumps back to the top of the page right after loading. Something in my skrollr.menu.init function seems to be doing the problem:

My project:
http://prbbi.com/services/pr/test/

So for example, if you go to this link, it jumps back to the top of the page after loading:
http://prbbi.com/services/pr/test/#reports

@Prinzhorn
Copy link
Owner

Please include the unminified sources. It's impossible to debug otherwise.

By the way it doesn't happen in Firefox for me, only Chrome.

@sdawson26
Copy link
Author

Prinzhorn,

Sorry about that. I've updated both Skrollr and Skrollr-menu to unminified.

Here is the file I'm calling the init from:

http://prbbi.com/js/pr/pr-footer.js

@Prinzhorn
Copy link
Owner

This was introduced by ebb39bba#diff-14e11108e3fcf79bc01a46d211744495R141

I'm not sure though why I thought it would be a good idea to fall back to 0 when the popstate event doesn't deliver any data. For some reason Chrome does fire a popstate when the page loads. I'm not sure about the consequences of ignoring popstate events which lack skrollr-menu specific data (which are the the counterpart to a skrollr-menu triggered pushstate).

@Prinzhorn
Copy link
Owner

Reading through #3 again maybe http://stackoverflow.com/questions/10742422/prevent-browser-scroll-on-html5-history-popstate was the reason for that. Because if I remove that code, then Chrome will scroll to the anchor by itself, which is not desired especially on mobile where this would break the page...

@Prinzhorn
Copy link
Owner

I'd need to take a closer look at this, but I'm busy. Maybe someone can play around with it and see what happens if the popstate is ignored, if it doesn't contain skrollr data.

@ir-Sindaco
Copy link

I am having the same exact issue, but i am not good enough to work out a solution. Hope someone can find a workaround soon!
edit: btw i am on a very tight schedule and need a fix asap (i would also gladly donate for the work if needed!)
i got some results simply by deleting the word "popstate" in the script, but then i get this: when clicking on an anchor from the first page menu (like productivity-and-performance-services.php#tire-pressure) i get to the correct section in the second page, but if i am already on the 2nd page and click the same link "productivity-and-performance-services.php#tire-pressure" it gets to a wrong position... while having a link and clicking #tire-pressure on the same 2nd page would work ok.
I could find a workaround to this as well (different links on different pages, so when i am on the 2nd page the menu links will point just to the #tire-pressure and not to the full productivity-and-performance-services.php#tire-pressure link) but there must be a better way. Also removing "popstate" might have side effects i am not aware of.
..hope i explained well enough!

@eudes
Copy link

eudes commented Mar 5, 2014

Same issue here: http://eudes.es/nova/test/index.html#organizar-evento
When loaded, page jumps to hash and immeditely afterwards jumps to the top.
Also, on mobile chrome there's a different issue:
When loaded the page jumps to hash, but you can't scroll up from there, only down. The size of the frame is the usual (whole page), but on the top of the page is the hashed position so you have half a blank page from the footer down.

@tslatt
Copy link

tslatt commented Feb 3, 2015

Has anyone found a solution yet?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants
@Prinzhorn @eudes @tslatt @sdawson26 @ir-Sindaco and others