use requestAnimationFrame for cleaner progress bar updates
This commit is contained in:
		
							parent
							
								
									41856c7ff9
								
							
						
					
					
						commit
						7a9dcfb6ec
					
				
					 1 changed files with 6 additions and 1 deletions
				
			
		|  | @ -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%"; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue