Skip to content

Instantly share code, notes, and snippets.

@leocunhadev
Created March 26, 2020 02:28
Show Gist options
  • Select an option

  • Save leocunhadev/1eb51c61d1bac1ea4cc884370c6ef9d4 to your computer and use it in GitHub Desktop.

Select an option

Save leocunhadev/1eb51c61d1bac1ea4cc884370c6ef9d4 to your computer and use it in GitHub Desktop.
// When the user scrolls the page, execute myFunction
window.onscroll = function() {myFunction()};
function myFunction() {
var winScroll = document.body.scrollTop || document.documentElement.scrollTop;
var height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
var scrolled = (winScroll / height) * 100;
var teste = document.querySelector('#teste');
document.getElementById("myBar").style.width = scrolled + "%";
if(scrolled >= 35){
teste.style.fontSize = (scrolled + 100) + '%';
console.log('ok');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment