skrollr-menu icon indicating copy to clipboard operation
skrollr-menu copied to clipboard

hash tag supplied not scrolled to when landing on the page, fix included

Open Blatant opened this issue 11 years ago • 9 comments

Currently when the skrollr js file is included, the url is parsed for hash tags and if skrollr is initialised issues the command to scroll to said id/name element.

However if like me you initialise the skrollr on document.ready (so you can do things like set dynamic key frames and position elements off the stage (right or bottom) skrollr is not initialised when the js file is loaded/parsed, and hence the command to scroll to the named anchor is ignored (you end at the top of the page each time thanks to the scrollTo(0,0) command).

I would suggest modifying as per :+1:

What I did first is locate the final function wrapped in a defer, which has had the if(document.querySelector)...statement remmed out, leaving the scrollTo(0,0) intact to stop the standard 'straight to hash' intact.

I then moved the entire function wrapped in the function (in the defer) to the end of skrollr.menu.init and remmed out the scrollTo(0,0). Now it works fine and dandy for me, and animates the scroll to the hash supplied after skrollr is initialised.

Blatant avatar Jul 24 '13 18:07 Blatant

I encountered this problem, too.

kidwm avatar Aug 29 '13 10:08 kidwm

I also had this problem... I found changing line 176 from handleLink(link, true); to handleLink(link, false); fixed it for me.

Not sure if this is the correct behavior?

kara-todd avatar Sep 09 '13 19:09 kara-todd

I tried changing line 176 but found no difference in the behavior

laltaffer avatar Sep 12 '13 22:09 laltaffer

Blatant - what do you mean 'remmed out' ? Its not a term I'm familiar with

Could you paste your final code?

laltaffer avatar Sep 12 '13 22:09 laltaffer

Please try version 0.1.6. It should work on mobile as well.

Prinzhorn avatar Oct 13 '13 11:10 Prinzhorn

Blatant - I also don't understand what you mean. Could you paste your final code?

tslatt avatar Feb 03 '15 15:02 tslatt

Hi tslatt,

It's been a long time and the site I used this on has since shut down, so I'm afraid I can't find the code again.

However if you see Prinzhorn's latest comment, it should be working now. Try giving the latest version a go, it would be my first port of call.

FYI: when I say "Remmed out" I simply meant "comment out the code" or just delete the line mentioned.

Blatant avatar Feb 03 '15 15:02 Blatant

It's not fixed in the latest version. But commenting out the defer function seems to fix the issues. Thanks!

tslatt avatar Feb 03 '15 16:02 tslatt

Glad I was able to help a little bit :)

Sorry I couldn't supply the code itself though. If I ever get the chance (work load) I'll see if I can retrieve the code form my Source Control and I'll copy it back here.

Blatant avatar Feb 03 '15 16:02 Blatant