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:
Ed Sanders 2015-03-23 02:32:00 +00:00
parent e50b74d906
commit e006449c7f

View file

@ -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 );
}