Currently, maybe because of scroll speed/latency, it's possible to get numbers greater than 1 or less than 0 (i.e. negative) at the extreme edges of the viewport. This would prevent that:
let per = (top + height) / (win + height); // <-- this line exists but uses `const` instead of `let`
// don't go out of bounds
if (per < 0) {
per = 0;
} else if (per > 1) {
per = 1;
}
Currently, maybe because of scroll speed/latency, it's possible to get numbers greater than 1 or less than 0 (i.e. negative) at the extreme edges of the viewport. This would prevent that: