mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-24 22:35:41 +00:00
Vertically center the progress bar within the visible part of #content
On short pages which don't extend below the fold, the progress bar should center within the #content element. Change-Id: I0b99e42f5bab8177d3b4ca6dd372d6403ae9b136
This commit is contained in:
parent
e50b74d906
commit
e006449c7f
|
@ -32,17 +32,15 @@
|
|||
'</div>'
|
||||
);
|
||||
}
|
||||
var $window = $( window ),
|
||||
$content = $( '#content' ),
|
||||
scrollTop = $window.scrollTop(),
|
||||
var $content = $( '#content' ),
|
||||
contentRect = $content[0].getBoundingClientRect(),
|
||||
offsetTop = $content.offset().top,
|
||||
windowHeight = $window.height();
|
||||
windowHeight = $( window ).height(),
|
||||
top = Math.max( contentRect.top, 0 ),
|
||||
bottom = Math.min( contentRect.bottom, windowHeight ),
|
||||
middle = ( top + bottom ) / 2;
|
||||
|
||||
if ( scrollTop > offsetTop ) {
|
||||
init.$loading.css( 'top', ( scrollTop - offsetTop ) + ( windowHeight / 2 ) );
|
||||
} else {
|
||||
init.$loading.css( 'top', ( windowHeight - ( offsetTop - scrollTop ) ) / 2 );
|
||||
}
|
||||
init.$loading.css( 'top', middle - offsetTop );
|
||||
|
||||
$content.prepend( init.$loading );
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue