Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add class active to nav-item #59

Closed
haidaraM opened this issue Nov 5, 2016 · 7 comments
Labels

Comments

@haidaraM
Copy link

@haidaraM haidaraM commented Nov 5, 2016

What do you think about adding the class active to the nav-items when scrolling and when the user clicks on them ?

You can find an example here : https://jsfiddle.net/cse_tushar/Dxtyu/141/

@gcushen

This comment has been minimized.

Copy link
Owner

@gcushen gcushen commented Nov 6, 2016

Originally, I actually implemented this kind of behaviour where a menu item is highlighted based on which section of the homepage the user is reading. However, I didn't commit my code for this feature because it cannot be 100% accurate. It will fail at the end of the page (the Contact widget will often not be highlighted since it has a short height). You cannot see the failure case in your example because your example sets each section as the screen height.

@haidaraM

This comment has been minimized.

Copy link
Author

@haidaraM haidaraM commented Nov 7, 2016

I see, you're right. I have not thought about it before.

@haidaraM haidaraM closed this Nov 7, 2016
@gcushen

This comment has been minimized.

Copy link
Owner

@gcushen gcushen commented Nov 7, 2016

It's quite a beautiful feature though, so I could still commit the code in the future if other users are happy with the trade-off in accuracy regarding the last couple of homepage sections.

@haidaraM

This comment has been minimized.

Copy link
Author

@haidaraM haidaraM commented Nov 7, 2016

yes, definitely a beautiful feature to have. Maybe with an option to enable it or not ?

@gcushen

This comment has been minimized.

Copy link
Owner

@gcushen gcushen commented Nov 7, 2016

Yes, that's an idea. I'll try to have another look into it and see if I can do that without making the code too complicated.

@haidaraM

This comment has been minimized.

Copy link
Author

@haidaraM haidaraM commented Nov 7, 2016

Nice. Thanks.
So I reopen the issue

@haidaraM haidaraM reopened this Nov 7, 2016
@gcushen

This comment has been minimized.

Copy link
Owner

@gcushen gcushen commented Nov 11, 2016

This feature has just been added in the ee33105 update. The active homepage menu item is now highlighted.

You can preview it in the latest demo: https://gcushen.github.io/hugo-academic-demo/

@gcushen gcushen closed this Nov 11, 2016
@gcushen gcushen added the enhancement label Nov 11, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.