Prinzhorn / skrollr-menu

skrollr plugin for hash navigation
MIT License
285 stars 143 forks source link

Scroll to section without click #60

Closed mulhoon closed 9 years ago

mulhoon commented 9 years ago

Great scripts! Best I've come across.

A tiny thing... Sometimes an issue arises when you may need to scroll to a section, but there isn't a link for it. To solve it, I just did this... (in jquery)

var link = $('<a/>');
link.attr('href', hash);
skrollr.menu.click(link[0]);

but it might be nice to just give skrollr-menu a hash to scroll to. Something like this...

skrollr.menu.goto(hash);
Prinzhorn commented 9 years ago

The skrollr.menu.click method does much more, because the link might have a data-menu-top attribute etc. The method you're suggesting would only be useful in limited use cases.

Maybe you should just use skrollr itself for it?

var position = $('#element-to-scroll-to').position().top;
skrollrInstance.animateTo(position);
mulhoon commented 9 years ago

Thanks, your answer makes a lot of sense.