/**
* Progress Bar
* @link https://www.billerickson.net/code/progress-bar/
*/
function ea_header_progress_bar() {
echo '<div class="progress"></div>';
}
add_action( 'tha_header_bottom', 'ea_header_progress_bar' );
// Progress Bar
$(document).on('ready', function() {
var winHeight = $(window).height(),
docHeight = $(document).height(),
progressBar = $('.site-header .progress'),
max, value;
/* Set the max scrollable area */
max = docHeight - winHeight;
$(document).on('scroll', function(){
value = $(window).scrollTop();
progressBar.css('width', value / max * 100 + '%' );
//progressBar.attr('value', value);
});
$(window).on('resize', function() {
winHeight = $(window).height(),
docHeight = $(document).height();
max = docHeight - winHeight;
progressBar.css('width', value / max * 100 + '%');
});
});