Changeset 26695
- Timestamp:
- 12/05/2013 10:21:15 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/js/widgets.js
r26651 r26695 441 441 widget.find( 'input.add_new' ).val(''); 442 442 443 $( 'html, body' ).animate({ 444 scrollTop: sidebar.offset().top - 130 445 }, 200 ); 443 /* 444 * Check if any part of the sidebar is visible in the viewport. If it is, don't scroll. 445 * Otherwise, scroll up to so the sidebar is in view. 446 * 447 * We do this by comparing the top and bottom, of the sidebar so see if they are within 448 * the bounds of the viewport. 449 */ 450 var viewport_top = $(window).scrollTop(), 451 viewport_bottom = viewport_top + $(window).height(), 452 sidebar_bounds = sidebar.offset(); 453 454 sidebar_bounds.bottom = sidebar_bounds.top + sidebar.outerHeight(); 455 456 if ( viewport_top > sidebar_bounds.bottom || viewport_bottom < sidebar_bounds.top ) { 457 $( 'html, body' ).animate({ 458 scrollTop: sidebar.offset().top - 130 459 }, 200 ); 460 } 446 461 447 462 window.setTimeout( function() {
Note: See TracChangeset
for help on using the changeset viewer.