Derrick is a digital native, finance geek and avid photographer. He loves spontaneity but is a control freak at the same time.

Leave a reply:

Your email address will not be published.

Site Footer

jQuery(document).ready( function($) { // get max length of article var getMax = function(){ return $(document).height() - $(window).height() - $('.top_menu_wrapper').height(); } // get current scroll position var getValue = function(){ return $(window).scrollTop() - $('.top_menu_wrapper').height(); } // if browser supports html5 progress element if ('max' in document.createElement('progress')) { // define progressbar element var progressBar = $('#reading_progress'); // set progressbar max attribute progressBar.attr({ max: getMax() }); // change progress bar attr values on scroll or resize $(window).on('resize scroll',function(){ progressBar.attr({ max: getMax(), value: getValue() }); }); } else { // if browser don't support html5 // get progress precent var setWidth = function() { // define progressbar element var progressBar = $('.reading-progress-bar'); // get max length of article var max = getMax(); // get current scroll position var value = getValue(); // set progress percent var width = (value/max) * 100; width = width + '%'; // set progress bar width style progressBar.css({ width: width }); } $(window).on('resize scroll', function(){ setWidth(); }); } // if sticky menu enabled, set top of progress bar if (jQuery('.invisible_header').length) { if (jQuery('.header_logo_wrapper .container').width() < 600) { var bartop = jQuery('.sticky_header').height(); } else { var offset = jQuery('.sticky_header').offset(); var bartop = offset.top + jQuery('.sticky_header').height(); } jQuery('#reading_progress.progress_sticky_header').css('top', bartop); } });