Admin menu:

- Fix scrolling the pinned menu with a mouse wheel.
- Fix pinning when the menu is only slightly taller than the viewport.
- Disable pinning on IE8, updating CSS top makes it jump when scrolling with a mouse wheel.
See #29806
Built from https://develop.svn.wordpress.org/trunk@29978


git-svn-id: http://core.svn.wordpress.org/trunk@29724 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Andrew Ozz 2014-10-21 06:12:20 +00:00
parent 2c8e435aa5
commit ecdc8d3baf
3 changed files with 43 additions and 22 deletions

View File

@ -177,6 +177,7 @@ $(document).ready( function() {
currentPage = pageInput.val(),
isIOS = /iPhone|iPad|iPod/.test( navigator.userAgent ),
isAndroid = navigator.userAgent.indexOf( 'Android' ) !== -1,
isIE8 = $( document.documentElement ).hasClass( 'ie8' ),
$document = $( document ),
$window = $( window ),
$body = $( document.body ),
@ -195,6 +196,7 @@ $(document).ready( function() {
menuTop = 0,
height = {
window: $window.height(),
wpwrap: $wpwrap.height(),
adminbar: $adminbar.height(),
menu: $adminMenuWrap.height()
};
@ -535,7 +537,12 @@ $(document).ready( function() {
function pinMenu() {
var windowPos = $window.scrollTop();
if ( isIOS || $adminmenu.data('wp-responsive') ) {
if ( isIOS || isIE8 || $adminmenu.data( 'wp-responsive' ) ) {
return;
}
if ( height.menu + height.adminbar + 20 > height.wpwrap ) { // 20px "buffer"
unpinMenu();
return;
}
@ -545,7 +552,11 @@ $(document).ready( function() {
if ( pinnedMenuTop ) {
// let it scroll
pinnedMenuTop = false;
menuTop = $adminMenuWrap.offset().top - height.adminbar;
menuTop = $adminMenuWrap.offset().top - height.adminbar - ( windowPos - lastScrollPosition );
if ( menuTop + height.menu + height.adminbar < windowPos + height.window ) {
menuTop = windowPos + height.window - height.menu - height.adminbar;
}
$adminMenuWrap.css({
position: 'absolute',
@ -567,7 +578,11 @@ $(document).ready( function() {
if ( pinnedMenuBottom ) {
// let it scroll
pinnedMenuBottom = false;
menuTop = $adminMenuWrap.offset().top - height.adminbar;
menuTop = $adminMenuWrap.offset().top - height.adminbar + ( lastScrollPosition - windowPos );
if ( menuTop + height.menu > windowPos + height.window ) {
menuTop = windowPos;
}
$adminMenuWrap.css({
position: 'absolute',
@ -587,13 +602,17 @@ $(document).ready( function() {
} else {
// Resizing
pinnedMenuTop = pinnedMenuBottom = false;
menuTop = $adminMenuWrap.offset().top - height.adminbar;
menuTop = windowPos + height.window - height.menu - height.adminbar - 1;
$adminMenuWrap.css({
position: 'absolute',
top: menuTop,
bottom: ''
});
if ( menuTop > 0 ) {
$adminMenuWrap.css({
position: 'absolute',
top: menuTop,
bottom: ''
});
} else {
unpinMenu();
}
}
}
@ -626,21 +645,10 @@ $(document).ready( function() {
}
}
setPinMenu();
if ( ! isIOS ) {
$window.on( 'scroll.pin-menu', pinMenu );
}
$document.on( 'wp-window-resized.pin-menu', function() {
height.window = $window.height();
height.adminbar = $adminbar.height();
setPinMenu();
}).on( 'wp-collapse-menu.pin-menu', function() {
height.menu = $adminMenuWrap.height();
setPinMenu();
});
window.wpResponsive = {
init: function() {
var self = this;
@ -775,6 +783,19 @@ $(document).ready( function() {
};
window.wpResponsive.init();
setPinMenu();
$document.on( 'wp-window-resized.pin-menu postboxes-columnchange.pin-menu postbox-toggled.pin-menu', function() {
height.wpwrap = $wpwrap.height();
height.window = $window.height();
height.adminbar = $adminbar.height();
setPinMenu();
}).on( 'wp-collapse-menu.pin-menu', function() {
height.wpwrap = $wpwrap.height();
height.menu = $adminMenuWrap.height();
setPinMenu();
});
});
// Fire a custom jQuery event at the end of window resize

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.1-alpha-20141020';
$wp_version = '4.1-alpha-20141021';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.