JSFiddle - React, Tailwind, and code Playground
HTML
<div class="number">0</div>
CSS
body {
height: 2000px;
}
.number {
position: fixed;
}
JavaScript
var body = document.body,
html = document.documentElement,
number = document.querySelector('.number'),
max = 300;
window.addEventListener('scroll', function() {
var scrollHeight = (html.scrollHeight || body.scrollHeight) - this.innerHeight,
scrollTop = html.scrollTop || body.scrollTop || 0;
number.innerHTML = Math.round(max / scrollHeight * scrollTop);
});