Twenty Seventeen: Fixes focused controls hidden by top menu.
When a page is scrolled, the top nav menu became fixed. This resolves that. Props afercia, Fencer04, davidakennedy Fixes #38476 git-svn-id: https://develop.svn.wordpress.org/trunk@39183 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
446dc73042
commit
208e443dc5
@ -26,6 +26,27 @@
|
|||||||
menuTop = 0,
|
menuTop = 0,
|
||||||
resizeTimer;
|
resizeTimer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ensure the sticky navigation doesn't cover current focused links
|
||||||
|
*/
|
||||||
|
$( '#content a, #colophon a' ).focus( function() {
|
||||||
|
if ( $navigation.hasClass( 'site-navigation-fixed' ) ) {
|
||||||
|
var windowScrollTop = $( window ).scrollTop(),
|
||||||
|
fixedNavHeight = $navigation.height(),
|
||||||
|
itemScrollTop = $( this ).offset().top,
|
||||||
|
offsetDiff = itemScrollTop - windowScrollTop;
|
||||||
|
|
||||||
|
// Account for Admin bar.
|
||||||
|
if ( $( '#wpadminbar' ).length ) {
|
||||||
|
offsetDiff -= $( '#wpadminbar' ).height();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( offsetDiff < fixedNavHeight ) {
|
||||||
|
$( window ).scrollTo( itemScrollTop - ( fixedNavHeight + 50 ), 600);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
} );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets properties of navigation
|
* Sets properties of navigation
|
||||||
*/
|
*/
|
||||||
|
@ -379,16 +379,13 @@ function twentyseventeen_scripts() {
|
|||||||
|
|
||||||
wp_enqueue_script( 'twentyseventeen-global', get_theme_file_uri( '/assets/js/global.js' ), array( 'jquery' ), '1.0', true );
|
wp_enqueue_script( 'twentyseventeen-global', get_theme_file_uri( '/assets/js/global.js' ), array( 'jquery' ), '1.0', true );
|
||||||
|
|
||||||
|
wp_enqueue_script( 'jquery-scrollto', get_theme_file_uri( '/assets/js/jquery.scrollTo.js' ), array( 'jquery' ), '2.1.2', true );
|
||||||
|
|
||||||
wp_localize_script( 'twentyseventeen-skip-link-focus-fix', 'twentyseventeenScreenReaderText', $twentyseventeen_l10n );
|
wp_localize_script( 'twentyseventeen-skip-link-focus-fix', 'twentyseventeenScreenReaderText', $twentyseventeen_l10n );
|
||||||
|
|
||||||
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
|
if ( is_singular() && comments_open() && get_option( 'thread_comments' ) ) {
|
||||||
wp_enqueue_script( 'comment-reply' );
|
wp_enqueue_script( 'comment-reply' );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scroll effects (only loaded on front page).
|
|
||||||
if ( is_front_page() ) {
|
|
||||||
wp_enqueue_script( 'jquery-scrollto', get_template_directory_uri() . '/assets/js/jquery.scrollTo.js', array( 'jquery' ), '2.1.2', true );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
add_action( 'wp_enqueue_scripts', 'twentyseventeen_scripts' );
|
add_action( 'wp_enqueue_scripts', 'twentyseventeen_scripts' );
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user