Make WordPress Core

Ticket #37313: 37313.diff

File 37313.diff, 1.3 KB (added by adamsilverstein, 9 years ago)
  • src/wp-admin/js/editor-expand.js

    diff --git src/wp-admin/js/editor-expand.js src/wp-admin/js/editor-expand.js
    index bf67c64..3b1f026 100644
     
    277277                        }
    278278                } );
    279279
     280                function debouncedScrollHandler() {
     281                        return _.debounce( function( event ) {
     282                                adjust( event.type );
     283                        }, 100 );
     284                }
     285
    280286                // Adjust the toolbars based on the active editor mode.
    281287                function adjust( event ) {
    282288                        // Make sure we're not in fullscreen mode.
     
    582588                        }
    583589                }
    584590
    585                 function afterScroll() {
    586                         clearTimeout( scrollTimer );
    587                         scrollTimer = setTimeout( adjust, 100 );
    588                 }
    589 
    590591                function on() {
    591592                        // Scroll to the top when triggering this from JS.
    592593                        // Ensures toolbars are pinned properly.
     
    597598                        $wrap.addClass( 'wp-editor-expand' );
    598599
    599600                        // Adjust when the window is scrolled or resized.
    600                         $window.on( 'scroll.editor-expand resize.editor-expand', function( event ) {
    601                                 adjust( event.type );
    602                                 afterScroll();
    603                         } );
     601                        $window.on( 'scroll.editor-expand resize.editor-expand', debouncedScrollHandler() );
    604602
    605603                        // Adjust when collapsing the menu, changing the columns, changing the body class.
    606604                        $document.on( 'wp-collapse-menu.editor-expand postboxes-columnchange.editor-expand editor-classchange.editor-expand', adjust )