Twenty Fifteen: unfix the sidebar if we have a menu with submenus as there is a chance visitors might not be able to scroll down to see submenus in some situations.

Props mattwiebe, fixes #30208.



git-svn-id: https://develop.svn.wordpress.org/trunk@30324 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ian Stewart 2014-11-13 03:08:21 +00:00
parent 5e730a0cf9
commit d97665d331
1 changed files with 17 additions and 6 deletions

View File

@ -50,11 +50,6 @@
// Sidebar (un)fixing: fix when short, un-fix when scroll needed
$body = $( 'body' );
$window = $( window );
sidebar = $( '#sidebar' )[0];
toolbarOffset = $body.is( '.admin-bar' ) ? $( '#wpadminbar' ).height() : 0;
function fixedOrScrolledSidebar() {
if ( $window.width() >= 955 ) {
if ( sidebar.scrollHeight < ( $window.height() - toolbarOffset ) ) {
@ -78,6 +73,22 @@
};
}
$window.on( 'load.twentyfifteen', fixedOrScrolledSidebar ).on( 'resize.twentyfifteen', debouncedFixedOrScrolledSidebar() );
$( document ).ready( function() {
// But! We only want to allow fixed sidebars when there are no submenus.
if ( $( '#site-navigation .sub-menu' ).length ) {
return;
}
// only initialize 'em if we need 'em
$body = $( 'body' );
$window = $( window );
sidebar = $( '#sidebar' )[0];
toolbarOffset = $body.is( '.admin-bar' ) ? $( '#wpadminbar' ).height() : 0;
$window
.on( 'load.twentyfifteen', fixedOrScrolledSidebar )
.on( 'resize.twentyfifteen', debouncedFixedOrScrolledSidebar() );
} );
} )( jQuery );