Skip to content

Instantly share code, notes, and snippets.

@jpen365
Created December 18, 2016 05:20
Show Gist options
  • Save jpen365/edcbd634fc0da14211e6fd504d6ff12c to your computer and use it in GitHub Desktop.
Save jpen365/edcbd634fc0da14211e6fd504d6ff12c to your computer and use it in GitHub Desktop.
Twenty Seventeen Full Height Featured Images Sticky Nav Fix
// Sticky nav on pages and posts
var body = jQuery( 'body' );
var navigation = body.find( '.navigation-top' );
var customHeader = body.find( '.custom-header' );
var navigationOuterHeight = navigation.outerHeight();
if ( body.hasClass( 'has-header-image' ) ) {
var headerOffset = customHeader.innerHeight() - navigationOuterHeight;
}
jQuery( window ).on( 'scroll', function() {
if ( jQuery( window ).scrollTop() >= headerOffset ) {
navigation.addClass( 'site-navigation-fixed' );
} else {
navigation.removeClass( 'site-navigation-fixed' );
}
});
@Zetalia
Copy link

Zetalia commented Jan 27, 2017

Hello Jon,

thank you for this snippet.
I would like to to try it on my installation, but cant figure out how to use it.
Can you please explain where to add this code in twentyseventeen?

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