jimmynotjim / scrollnav

A dependency free JavaScript plugin for auto generating single page navigation
http://scrollnav.com
MIT License
461 stars 127 forks source link

Scroll positions won't update when content changes #46

Closed noelrivasc closed 10 years ago

noelrivasc commented 10 years ago

If sections have elements that are shown / hidden on user interaction (changing the content height), the scroll positions won't match the menu items, since the section positions is only calculated on init.

One fix is: $(window).on('click.scrollNav', function() { $.fn.scrollNav('_setup_pos'); });

This makes scrollNav update the positions each time the user clicks an element. It only works on click, obviously, but a call to scrollNav('_setup_pos') can be added to any event that will change the content height.

I don't think this is a bug, but a method could be provided to update the section positions, or this could be mentioned in the docs.

Awesome plugin, thank you =)

jimmynotjim commented 10 years ago

Thanks for catching this, it's not something I'd come across before. I agree a new method to update the positions is the way to go. I'll try to work this into the plugin soon.

jimmynotjim commented 10 years ago

@nelovishk Could you take a look at #53 and if possible test it against your use case? I'm preparing this for release but want to make sure we're covering everything.