Skip to content

Instantly share code, notes, and snippets.

@patrickposner
Created December 7, 2018 11:27
Show Gist options
  • Select an option

  • Save patrickposner/cce38b5127f227a0951b6e3754a93e81 to your computer and use it in GitHub Desktop.

Select an option

Save patrickposner/cce38b5127f227a0951b6e3754a93e81 to your computer and use it in GitHub Desktop.
if ( $('body').hasClass('single-post') ) {
window.addEventListener('scroll', function(e) {
var s = (window.pageYOffset !== undefined) ? window.pageYOffset : (document.documentElement || document.body.parentNode || document.body).scrollTop;
var body = document.body;
var html = document.documentElement;
var d = Math.max(body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight);
var c = window.innerHeight;
var position = (s / (d - c)) * 100;
if ( $( "#atomion-progress-bar" ).length ) {
$( "#atomion-progress-bar" ).css('width', position + '%');
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment