diff --git a/static/js/upload.js b/static/js/upload.js index 9ec6e79..31dc08c 100644 --- a/static/js/upload.js +++ b/static/js/upload.js @@ -31,6 +31,7 @@ let progressSize; let progressRate; let progressEta; let progressBar; +let animationID = null; window.addEventListener('beforeunload', (event) => { if (socket && socket.readyState !== 3) { @@ -291,7 +292,9 @@ function sendData() { if (timestamps.length > SAMPLE_WINDOW) { timestamps.shift(); } } - updateProgress(); + if (animationID === null) { + animationID = requestAnimationFrame(updateProgress); + } } else { fileIndex += 1; byteIndex = 0; @@ -300,6 +303,8 @@ function sendData() { } function updateProgress() { + animationID = null; + let percentage; if (totalBytes === 0) { percentage = "0%";