[progress] Progress Bar Doesn't Update within Loops #1937
-
Bug ReportWhen trying to update the progress bar multiple times in a loop, the progress bar doesn't update until the loop has completed, rather than once per iteration. Steps to reproduce
Expected resultAfter each iteration, the progress bar increases by one percent Actual resultAfter the final iteration, the progress bar increases by ten percent Testcasehttps://jsfiddle.net/bw0uxkje/ Screenshot (if possible)Fomantic-UI.Sandbox.-.JSFiddle.-.Code.Playground.-.Personal.-.Microsoft.Edge.2021-03-28.17-11-08.mp4Version2.8.7 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This is not a bug in Fomantic, but the nature of Javascript and browser handling. The DOM won't be updated by the browser until the current running Javascript ends. As you are triggering the Progress multiple times inside a running loop, only the final result will be shown when the outer for loop ends. Two technical solutions: Use Use |
Beta Was this translation helpful? Give feedback.
This is not a bug in Fomantic, but the nature of Javascript and browser handling. The DOM won't be updated by the browser until the current running Javascript ends. As you are triggering the Progress multiple times inside a running loop, only the final result will be shown when the outer for loop ends.
Two technical solutions:
Use
requestAnimationFrame
... But this is, according to your example, still too fast as it will wait for the next vsync of your graphics card, but you can at least see it will handle the progress update individually.https://jsfiddle.net/lubber/r056x7td/15/
Use
setTimeOut
to handle each progress update in a separate js context. This shows every progress update accord…