Merge "Only use pre-computed measurements for position loading bar"

This commit is contained in:
jenkins-bot 2018-03-20 21:44:36 +00:00 committed by Gerrit Code Review
commit 0ed47a025e

View file

@ -36,7 +36,7 @@
plugins = [];
function showLoading( mode ) {
var $content, contentRect, offsetTop, windowHeight, top, bottom, middle, loadingTop;
var $content, windowHeight, clientTop, top, bottom, middle;
if ( isLoading ) {
return;
@ -61,14 +61,12 @@
$content = $( '#content' );
if ( mode !== 'source' ) {
// Center within visible part of the target
contentRect = $content[ 0 ].getBoundingClientRect();
windowHeight = $( window ).height();
top = Math.max( contentRect.top, 0 );
bottom = Math.min( contentRect.bottom, windowHeight );
windowHeight = window.innerHeight;
clientTop = $content[ 0 ].offsetTop - window.pageYOffset;
top = Math.max( clientTop, 0 );
bottom = Math.min( clientTop + $content[ 0 ].offsetHeight, windowHeight );
middle = ( bottom - top ) / 2;
offsetTop = Math.max( -contentRect.top, 0 );
loadingTop = middle + offsetTop;
init.$loading.css( 'top', loadingTop );
init.$loading.css( 'top', middle + Math.max( -clientTop, 0 ) );
}
$content.prepend( init.$loading );