Make WordPress Core

Changeset 29656


Ignore:
Timestamp:
09/01/2014 06:48:07 PM (12 years ago)
Author:
azaozz
Message:

Editor expand:

  • Adjust calculation when comparing sidebar position to wpfooter top. Fixes an annoying jumping when the user scrolls off the bottom.
  • Use a var for the 'bottom' distance of the sidebar.
  • Fix sidebar pinning when it's height is nearly the same as the viewport height.

Fixes #29349

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/js/editor-expand.js

    r29628 r29656  
    3434                pageYOffsetAtTop = 130,
    3535                pinnedToolsTop = 56,
     36                sidebarBottom = 20,
    3637                autoresizeMinHeight = 300,
    3738                initialMode = window.getUserSetting( 'editor' ),
    … …  
    433434                        heights.windowHeight < editorHeight ) { // the editor is taller than the viewport
    434435
    435                         if ( heights.sideSortablesHeight > heights.windowHeight || fixedSideTop || fixedSideBottom ) {
     436                        if ( ( heights.sideSortablesHeight + pinnedToolsTop + sidebarBottom ) > heights.windowHeight || fixedSideTop || fixedSideBottom ) {
    436437                                // Reset when scrolling to the top
    437438                                if ( windowPos + pinnedToolsTop <= postBodyTop ) {
    … …  
    448449
    449450                                                        // don't get over the footer
    450                                                         if ( footerTop < sidebarTop + heights.sideSortablesHeight + 20 ) {
    451                                                                 sidebarTop = footerTop - heights.sideSortablesHeight - 20;
     451                                                        if ( footerTop < sidebarTop + heights.sideSortablesHeight + sidebarBottom ) {
     452                                                                sidebarTop = footerTop - heights.sideSortablesHeight - 12;
    452453                                                        }
    453454
    … …  
    457458                                                                bottom: ''
    458459                                                        });
    459                                                 } else if ( ! fixedSideBottom && heights.sideSortablesHeight + $sideSortables.offset().top + 20 < windowPos + heights.windowHeight ) {
     460                                                } else if ( ! fixedSideBottom && heights.sideSortablesHeight + $sideSortables.offset().top + sidebarBottom < windowPos + heights.windowHeight ) {
    460461                                                        // pin the bottom
    461462                                                        fixedSideBottom = true;
    … …  
    464465                                                                position: 'fixed',
    465466                                                                top: 'auto',
    466                                                                 bottom: '20px'
     467                                                                bottom: sidebarBottom
    467468                                                        });
    468469                                                }
    … …  
    472473                                                        // let it scroll
    473474                                                        fixedSideBottom = false;
    474                                                         sidebarTop = $sideSortables.offset().top - 20;
     475                                                        sidebarTop = $sideSortables.offset().top - sidebarBottom;
    475476                                                        footerTop = $footer.offset().top;
    476477
    477478                                                        // don't get over the footer
    478                                                         if ( footerTop < sidebarTop + heights.sideSortablesHeight + 20 ) {
    479                                                                 sidebarTop = footerTop - heights.sideSortablesHeight - 20;
     479                                                        if ( footerTop < sidebarTop + heights.sideSortablesHeight + sidebarBottom ) {
     480                                                                sidebarTop = footerTop - heights.sideSortablesHeight - 12;
    480481                                                        }
    481482
    … …  
    500501                                // if the sidebar container is smaller than the viewport, then pin/unpin the top when scrolling
    501502                                if ( windowPos >= ( postBodyTop - pinnedToolsTop ) ) {
     503
    502504                                        $sideSortables.css( {
    503505                                                position: 'fixed',
    … …  
    570572                $document.on( 'wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand', adjust )
    571573                        .on( 'postbox-toggled.editor-expand', function() {
    572                                 if ( ! fixedSideTop && ! fixedSideBottom && window.pageYOffset > 20 ) {
     574                                if ( ! fixedSideTop && ! fixedSideBottom && window.pageYOffset > pinnedToolsTop ) {
    573575                                        fixedSideBottom = true;
    574576                                        window.scrollBy( 0, -1 );
Note: See TracChangeset for help on using the changeset viewer.