Twenty Fifteen: correcting odd scrolling and jumping in IE and no-scroll with window resize.

Props iamtakashi, ocean90, fixes #30632, #30645.



Built from https://develop.svn.wordpress.org/trunk@30808


git-svn-id: http://core.svn.wordpress.org/trunk@30798 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ian Stewart 2014-12-10 23:02:23 +00:00
parent 65ed77974b
commit d3adc02051
1 changed files with 9 additions and 10 deletions

View File

@ -6,9 +6,9 @@
*/ */
( function( $ ) { ( function( $ ) {
var $body, $window, $document, $sidebar, adminbarOffset, top = false, var $body, $window, $sidebar, adminbarOffset, top = false,
bottom = false, windowWidth, windowHeight, lastWindowPos = 0, bottom = false, windowWidth, windowHeight, lastWindowPos = 0,
topOffset = 0, documentHeight, sidebarHeight, resizeTimer; topOffset = 0, bodyHeight, sidebarHeight, resizeTimer;
// Add dropdown toggle that display child menu items. // Add dropdown toggle that display child menu items.
$( '.main-navigation .page_item_has_children > a, .main-navigation .menu-item-has-children > a' ).after( '<button class="dropdown-toggle" aria-expanded="false">' + screenReaderText.expand + '</button>' ); $( '.main-navigation .page_item_has_children > a, .main-navigation .menu-item-has-children > a' ).after( '<button class="dropdown-toggle" aria-expanded="false">' + screenReaderText.expand + '</button>' );
@ -52,9 +52,9 @@
// Sidebar scrolling. // Sidebar scrolling.
function resize() { function resize() {
windowWidth = $window.width(); windowWidth = $window.width();
windowHeight = $window.height(); windowHeight = $window.height();
documentHeight = $document.height(); bodyHeight = $body.height();
sidebarHeight = $sidebar.height(); sidebarHeight = $sidebar.height();
if ( 955 > windowWidth ) { if ( 955 > windowWidth ) {
@ -66,7 +66,7 @@
function scroll() { function scroll() {
var windowPos = $window.scrollTop(); var windowPos = $window.scrollTop();
if ( 955 <= windowWidth && sidebarHeight + adminbarOffset < documentHeight ) { if ( 955 <= windowWidth && sidebarHeight + adminbarOffset < bodyHeight ) {
if ( sidebarHeight + adminbarOffset > windowHeight ) { if ( sidebarHeight + adminbarOffset > windowHeight ) {
if ( windowPos > lastWindowPos ) { if ( windowPos > lastWindowPos ) {
if ( top ) { if ( top ) {
@ -106,10 +106,9 @@
} }
$( document ).ready( function() { $( document ).ready( function() {
$body = $( 'body' ); $body = $( document.body );
$window = $( window ); $window = $( window );
$document = $( document ); $sidebar = $( '#sidebar' ).first();
$sidebar = $( '#sidebar' ).first();
adminbarOffset = $body.is( '.admin-bar' ) ? $( '#wpadminbar' ).height() : 0; adminbarOffset = $body.is( '.admin-bar' ) ? $( '#wpadminbar' ).height() : 0;
$window $window