Create a callback to update the bars
const bar = document.querySelector(".bar");
const svg = document.querySelector("svg");
const circle = svg.querySelector("circle");
const r = circle.getAttribute("r");
const circ = 2 * Math.PI * r;
// callback to update the progress bars
function update(data) {
const pos = 1 - ((data.max - data.scrolled) / data.max);
// update radial progress bar
circle.style.strokeDashoffset = circ - (circ * pos);
// update linear progress bar
bar.style.transform = `scale(${pos}, 1)`;
}