Skip to content

Instantly share code, notes, and snippets.

@dhenson02
Last active August 29, 2015 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dhenson02/59dbe11fa2371c15ae99 to your computer and use it in GitHub Desktop.
Save dhenson02/59dbe11fa2371c15ae99 to your computer and use it in GitHub Desktop.
nginx-theme scroll sticky-menu fix

Your sticky-menu was broked, so I fixed it.

CSS

Problem:

#masthead is getting yanked from the layout and everything after it gets forced up to fill the 70px gap.

Solution:

Never put it in the layout flow to begin with. Use absolute positioning and recover the lost 70px with padding.

JS

Problem:

Looks like a copy + paste accident from the lines above them. If you scroll to "< 150", you are already "< 200" so both conditions fire at once almost.

Solution:

Check for the bigger number first.

#masthead {
position: absolute;
}
#masthead + div {
padding-top: 70px;
}
/*...*/
function scroll_effect() {
/*...line 174...*/
if (currentScrollValue < 200) {
/*...*/
if (currentScrollValue < 150) {
/*...*/
}
}
}
@dhenson02
Copy link
Author

PS - looks great when it works the way you intended it to :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment