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

toggling sticky top navbar makes page jump to top on small screens #11

Open
phivk opened this issue May 25, 2017 · 3 comments
Open

toggling sticky top navbar makes page jump to top on small screens #11

phivk opened this issue May 25, 2017 · 3 comments

Comments

@phivk
Copy link

phivk commented May 25, 2017

On small screens (when the top nav bar is presented with a hamburger menu icon) and the user has scrolled enough for the navbar to be positioned fixed to top, clicking the top right "menu"+icon (li.toggle-topbar.menu-icon) element makes the the page 'jump to top'.

This looses the orientation on the page and can be confusing to the user. A more straightforward behaviour would be simply to expand the nav bar element while keeping the scroll position the same.

I've looked into user/themes/gateway/js/foundation.js and found the scrolltop option in the settings object of Foundation.libs.topbar. I've tried setting scrolltop to false, which results in expected behaviour when the top nav bar is in fixed positioning (scrolled), but causes the nav bar element to be positioned to the top of the page when clicked while it is not initially in fixed positioning (not scrolled).

To summarise the states that are buggy:

scrolltop \ position fixed (scrolled) relative (not scrolled)
true ❌ page jumps to top
false ❌ nav bar element at page top
@phivk
Copy link
Author

phivk commented May 25, 2017

the issue of 'nav bar element at page top' (when scrolltop is false and user has not scrolled) seems to be caused by these lines in user/themes/gateway/js/foundation.js:

if (self.is_sticky(topbar, topbar.parent(), settings)) {
    topbar.parent().addClass('fixed');
}

Removing these lines fixes the 'nav bar element at page top' issue (bottom right in above table) for me.

@phivk
Copy link
Author

phivk commented May 25, 2017

as for the 'page jumps to top' issue, I guess this is might be a feature rather than a bug, considering it's presented like this in the settings:

scrolltop : true, // jump to top when sticky nav menu toggle is clicked

I still consider the 'nav bar element at page top' issue a bug. I'm happy to submit a PR with my fix for it if maintainers agree?

@gravaholic
Copy link

Hi, what is the solution?

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

No branches or pull requests

2 participants