Changeset 29978
- Timestamp:
- 10/21/2014 06:11:07 AM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/common.js
r29898 r29978 178 178 isIOS = /iPhone|iPad|iPod/.test( navigator.userAgent ), 179 179 isAndroid = navigator.userAgent.indexOf( 'Android' ) !== -1, 180 isIE8 = $( document.documentElement ).hasClass( 'ie8' ), 180 181 $document = $( document ), 181 182 $window = $( window ), … … 196 197 height = { 197 198 window: $window.height(), 199 wpwrap: $wpwrap.height(), 198 200 adminbar: $adminbar.height(), 199 201 menu: $adminMenuWrap.height() … … 536 538 var windowPos = $window.scrollTop(); 537 539 538 if ( isIOS || $adminmenu.data('wp-responsive') ) { 540 if ( isIOS || isIE8 || $adminmenu.data( 'wp-responsive' ) ) { 541 return; 542 } 543 544 if ( height.menu + height.adminbar + 20 > height.wpwrap ) { // 20px "buffer" 545 unpinMenu(); 539 546 return; 540 547 } … … 546 553 // let it scroll 547 554 pinnedMenuTop = false; 548 menuTop = $adminMenuWrap.offset().top - height.adminbar; 555 menuTop = $adminMenuWrap.offset().top - height.adminbar - ( windowPos - lastScrollPosition ); 556 557 if ( menuTop + height.menu + height.adminbar < windowPos + height.window ) { 558 menuTop = windowPos + height.window - height.menu - height.adminbar; 559 } 549 560 550 561 $adminMenuWrap.css({ … … 568 579 // let it scroll 569 580 pinnedMenuBottom = false; 570 menuTop = $adminMenuWrap.offset().top - height.adminbar; 581 menuTop = $adminMenuWrap.offset().top - height.adminbar + ( lastScrollPosition - windowPos ); 582 583 if ( menuTop + height.menu > windowPos + height.window ) { 584 menuTop = windowPos; 585 } 571 586 572 587 $adminMenuWrap.css({ … … 588 603 // Resizing 589 604 pinnedMenuTop = pinnedMenuBottom = false; 590 menuTop = $adminMenuWrap.offset().top - height.adminbar; 591 592 $adminMenuWrap.css({ 593 position: 'absolute', 594 top: menuTop, 595 bottom: '' 596 }); 605 menuTop = windowPos + height.window - height.menu - height.adminbar - 1; 606 607 if ( menuTop > 0 ) { 608 $adminMenuWrap.css({ 609 position: 'absolute', 610 top: menuTop, 611 bottom: '' 612 }); 613 } else { 614 unpinMenu(); 615 } 597 616 } 598 617 } … … 627 646 } 628 647 629 setPinMenu();630 631 648 if ( ! isIOS ) { 632 649 $window.on( 'scroll.pin-menu', pinMenu ); 633 650 } 634 635 $document.on( 'wp-window-resized.pin-menu', function() {636 height.window = $window.height();637 height.adminbar = $adminbar.height();638 setPinMenu();639 }).on( 'wp-collapse-menu.pin-menu', function() {640 height.menu = $adminMenuWrap.height();641 setPinMenu();642 });643 651 644 652 window.wpResponsive = { … … 776 784 777 785 window.wpResponsive.init(); 786 setPinMenu(); 787 788 $document.on( 'wp-window-resized.pin-menu postboxes-columnchange.pin-menu postbox-toggled.pin-menu', function() { 789 height.wpwrap = $wpwrap.height(); 790 height.window = $window.height(); 791 height.adminbar = $adminbar.height(); 792 setPinMenu(); 793 }).on( 'wp-collapse-menu.pin-menu', function() { 794 height.wpwrap = $wpwrap.height(); 795 height.menu = $adminMenuWrap.height(); 796 setPinMenu(); 797 }); 798 778 799 }); 779 800
Note: See TracChangeset
for help on using the changeset viewer.