- Timestamp:
- 12/15/2014 12:10:18 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/common.js
r30844 r30852 194 194 pinnedMenuTop = false, 195 195 pinnedMenuBottom = false, 196 isScrolling = false,197 scrollTimer,198 196 menuTop = 0, 197 menuIsPinned = false, 199 198 height = { 200 document: $document.height(),201 199 window: $window.height(), 202 200 wpwrap: $wpwrap.height(), … … 545 543 })(); 546 544 547 function pinMenu() { 548 var windowPos = $window.scrollTop(); 545 function pinMenu( event ) { 546 var windowPos = $window.scrollTop(), 547 resizing = ! event || event.type !== 'scroll'; 549 548 550 549 if ( isIOS || isIE8 || $adminmenu.data( 'wp-responsive' ) ) { … … 552 551 } 553 552 554 if ( height.menu + height.adminbar + 20 > height.wpwrap ) { // 20px "buffer" 553 if ( height.menu + height.adminbar < height.window || 554 height.menu + height.adminbar + 20 > height.wpwrap ) { 555 555 unpinMenu(); 556 556 return; 557 557 } 558 559 menuIsPinned = true; 558 560 559 561 if ( height.menu + height.adminbar > height.window ) { … … 572 574 573 575 return; 574 } else if ( windowPos + height.window > height.document- 1 ) {576 } else if ( windowPos + height.window > $document.height() - 1 ) { 575 577 if ( ! pinnedMenuBottom ) { 576 578 pinnedMenuBottom = true; … … 639 641 }); 640 642 } 641 } else {643 } else if ( resizing ) { 642 644 // Resizing 643 645 pinnedMenuTop = pinnedMenuBottom = false; … … 661 663 function resetHeights() { 662 664 height = { 663 document: $document.height(),664 665 window: $window.height(), 665 666 wpwrap: $wpwrap.height(), … … 670 671 671 672 function unpinMenu() { 672 if ( isIOS ) {673 if ( isIOS || ! menuIsPinned ) { 673 674 return; 674 675 } 675 676 676 pinnedMenuTop = pinnedMenuBottom = false;677 pinnedMenuTop = pinnedMenuBottom = menuIsPinned = false; 677 678 $adminMenuWrap.css({ 678 679 position: '', … … 697 698 } 698 699 699 function scrollStart() {700 if ( isScrolling ) {701 window.clearTimeout( scrollTimer );702 703 scrollTimer = window.setTimeout( function() {704 isScrolling = false;705 }, 200 );706 } else {707 isScrolling = true;708 $document.triggerHandler( 'wp-scroll-start' );709 }710 }711 712 700 if ( ! isIOS ) { 713 $window.on( 'scroll.pin-menu', function() {714 scrollStart();715 pinMenu();701 $window.on( 'scroll.pin-menu', pinMenu ); 702 $document.on( 'tinymce-editor-init.pin-menu', function( event, editor ) { 703 editor.on( 'wp-autoresize', resetHeights ); 716 704 }); 717 705 }
Note: See TracChangeset
for help on using the changeset viewer.