JSFiddle - React, Tailwind, and code Playground
HTML
<span id="count">150</span>
CSS
html, body {
height: 1000%;
}
#count {
position: fixed;
}
JavaScript
var counter = document.getElementById('count');
function updateCounter() {
'use strict';
var height = document.documentElement.scrollHeight - window.innerHeight;
counter.textContent = 150 - document.documentElement.scrollTop / height * 150;
}
document.addEventListener('scroll', updateCounter);
window.addEventListener('resize', updateCounter);