Position VE desktop loading bar with position:fixed

This doesn't change the position of the loading bar, but it keeps it
still if any scrolling happens. Previously we expected the user probably
wouldn't scroll while VE is loading, but in subsequent commits we
will trigger automatic scrolling in section editing mode.

Change-Id: I1404ccd77583d808ef79291c6cb4f561e76bd41c
This commit is contained in:
Ed Sanders 2022-01-24 12:47:05 +00:00
parent d1aaf3d451
commit 6f5fe8cdb0
2 changed files with 22 additions and 14 deletions

View file

@ -95,12 +95,17 @@
/* stylelint-enable selector-max-id */
.ve-init-mw-desktopArticleTarget-loading-overlay {
position: absolute;
/* Center progress bar within toolbar */
top: 0.875em;
left: 0;
right: 0;
z-index: 1;
&-visual {
position: fixed;
}
&-source {
position: absolute;
width: 100%;
top: 0.875em;
}
}
.ve-init-mw-desktopArticleTarget-toolbarPlaceholder {

View file

@ -55,17 +55,20 @@
// eslint-disable-next-line no-use-before-define
$( document ).on( 'keydown', onDocumentKeyDown );
init.$loading.toggleClass( 've-init-mw-desktopArticleTarget-loading-overlay-source', mode === 'source' );
init.$loading.toggleClass( 've-init-mw-desktopArticleTarget-loading-overlay-visual', mode === 'visual' );
var $content = $( '#content' );
if ( mode !== 'source' ) {
// Center within visible part of the target
var windowHeight = window.innerHeight;
var clientTop = $content[ 0 ].offsetTop - window.pageYOffset;
var top = Math.max( clientTop, 0 );
var bottom = Math.min( clientTop + $content[ 0 ].offsetHeight, windowHeight );
var middle = ( bottom - top ) / 2;
init.$loading.css( 'top', middle + Math.max( -clientTop, 0 ) );
if ( mode === 'visual' ) {
init.$loading.css( {
top: window.innerHeight / 2,
width: $content.outerWidth()
} );
} else {
init.$loading.css( 'top', '' );
init.$loading.css( {
top: '',
width: ''
} );
}
$content.prepend( init.$loading );