Make WordPress Core

Changeset 27798


Ignore:
Timestamp:
03/27/2014 11:12:25 PM (11 years ago)
Author:
ocean90
Message:

Widget Customizer: Improve behavior of bigger widgets.

  • Support widgets which are higher than browsers viewport.
  • Use widgets width as max-width.
  • Don't animate the width of wide widgets to make them visible, instead fade them in/out.
  • Fix Chrome flickerings while updating wide widgets.

props adamsilverstein, westonruter, ocean90.
see #27348.

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/customize-widgets.css

    r27790 r27798  
    5151    max-width: 100%;
    5252}
     53
    5354.customize-control-widget_form.wide-widget-control .widget-inside {
    5455    position: fixed;
    5556    left: 299px;
    5657    top: 25%;
     58    border: 1px solid rgb(229, 229, 229);
     59    overflow: auto;
     60}
     61.customize-control-widget_form.wide-widget-control .widget-inside > .form {
    5762    padding: 20px;
    58     border: 1px solid rgb(229, 229, 229);
    59     z-index: -1;
    60 }
    61 .customize-control-widget_form.wide-widget-control.collapsing .widget-inside {
    62     z-index: -2;
    6363}
    6464
  • trunk/src/wp-admin/js/customize-widgets.js

    r27701 r27798  
    704704            var control = this,
    705705                widget_inside,
     706                widget_form,
    706707                customize_sidebar,
    707708                position_widget,
     
    713714
    714715            widget_inside = control.container.find( '.widget-inside' );
     716            widget_form = widget_inside.find( '> .form' );
    715717            customize_sidebar = $( '.wp-full-overlay-sidebar-content:first' );
    716718            control.container.addClass( 'wide-widget-control' );
    717719
    718720            control.container.find( '.widget-content:first' ).css( {
    719                 'min-width': control.params.width,
     721                'max-width': control.params.width,
    720722                'min-height': control.params.height
    721723            } );
     
    726728             * widget-top is scrolled out of view, keep the widget-top in view;
    727729             * likewise, don't allow the widget to drop off the bottom of the window.
     730             * If a widget is too tall to fit in the window, don't let the height
     731             * exceed the window height so that the contents of the widget control
     732             * will become scrollable (overflow:auto).
    728733             */
    729734            position_widget = function () {
    730735                var offset_top = control.container.offset().top,
    731                     height,
    732                     top,
    733                     max_top;
    734 
    735                 height = widget_inside.outerHeight();
    736                 top = Math.max( offset_top, 0 );
    737                 max_top = $( window ).height() - height;
    738                 top = Math.min( top, max_top );
     736                    window_height = $( window ).height(),
     737                    form_height = widget_form.outerHeight(),
     738                    top;
     739                widget_inside.css( 'max-height', window_height );
     740                top = Math.max(
     741                    0, // prevent top from going off screen
     742                    Math.min(
     743                        Math.max( offset_top, 0 ), // distance widget in panel is from top of screen
     744                        window_height - form_height // flush up against bottom of screen
     745                    )
     746                );
    739747                widget_inside.css( 'top', top );
    740748            };
     
    742750            theme_controls_container = $( '#customize-theme-controls' );
    743751            control.container.on( 'expand', function () {
     752                position_widget();
    744753                customize_sidebar.on( 'scroll', position_widget );
    745754                $( window ).on( 'resize', position_widget );
    746755                theme_controls_container.on( 'expanded collapsed', position_widget );
    747                 position_widget();
    748756            } );
    749757            control.container.on( 'collapsed', function () {
    750758                customize_sidebar.off( 'scroll', position_widget );
     759                $( window ).off( 'resize', position_widget );
    751760                theme_controls_container.off( 'expanded collapsed', position_widget );
    752                 $( window ).off( 'resize', position_widget );
    753761            } );
    754762
     
    13761384            }
    13771385
    1378             complete;
    13791386            if ( do_expand ) {
    13801387                // Close all other widget controls before expanding this one
     
    13851392                } );
    13861393
    1387                 control.container.trigger( 'expand' );
    1388                 control.container.addClass( 'expanding' );
    13891394                complete = function () {
    13901395                    control.container.removeClass( 'expanding' );
     
    13931398                };
    13941399                if ( control.params.is_wide ) {
    1395                     inside.animate( { width: 'show' }, 'fast', complete );
     1400                    inside.fadeIn( 'fast', complete );
    13961401                } else {
    13971402                    inside.slideDown( 'fast', complete );
    13981403                }
     1404                control.container.trigger( 'expand' );
     1405                control.container.addClass( 'expanding' );
    13991406            } else {
    14001407                control.container.trigger( 'collapse' );
     
    14061413                };
    14071414                if ( control.params.is_wide ) {
    1408                     inside.animate( { width: 'hide' }, 'fast', complete );
     1415                    inside.fadeOut( 'fast', complete );
    14091416                } else {
    14101417                    inside.slideUp( 'fast', function() {
Note: See TracChangeset for help on using the changeset viewer.