11 lines
No EOL
350 B
JavaScript
11 lines
No EOL
350 B
JavaScript
var h = document.documentElement,
|
|
b = document.body,
|
|
st = 'scrollTop',
|
|
sh = 'scrollHeight',
|
|
progress = document.querySelector('.progress'),
|
|
scroll;
|
|
|
|
document.addEventListener('scroll', function() {
|
|
scroll = (h[st]||b[st]) / ((h[sh]||b[sh]) - h.clientHeight) * 100;
|
|
progress.style.setProperty('--scroll', scroll + '%');
|
|
}); |