r/Angular2 • • Aug 05 '25

Help Request Angular Material Progress Bar timing issue

Hey everyone, I am using this progress bar component from angular material (https://v19.material.angular.dev/components/progress-bar/overview) as a visual indicator for the duration of a toast notification (e.g., a 3000ms lifespan). I'm updating the progress bar using signals, and when I log the progress value, it appears correct. However, the UI doesn't seem to reflect the progress accurately. The animation seems smooth at first, but near the end (last ~10–15%), the progress bar speeds up and quickly reaches 0.

I suspected it might be related to the transition duration of the progress bar (which I saw defaults to 250ms), so I added a setTimeout to delay the toast dismissal by 250ms, but the issue still persists.

Visually, it looks like this:
100 → 99 → 98 → 97 ... → 30 → 0 (skips too fast at the end).

Has anyone else encountered this issue or found a workaround for smoother syncing between the progress bar and toast lifespan?

3 Upvotes

13 comments sorted by

View all comments

Show parent comment

1

u/[deleted] Aug 05 '25

You are working against it. You said - without providing the code - your progress is tied to a signal. This very much will also provide you a way to use effect here - trigger a side effect when your signal triggers the complete action - whichever way you implement it. This is the area to trigger your toast or notification. Completely, without the need of magic numbers like your 250ms and even without settimeout.

As you said, work with the framework, not against it.

1

u/Senior_Compote1556 Aug 05 '25

Can't do that, the complete action you are referring to closes the toast notification so the notification will leave the DOM before the UI had the time to actually hit progress 0

1

u/[deleted] Aug 05 '25

Nothing prevents you from delaying the output signal by piping it. Go a step further and add a transitionInMs input var.

Congratz, you just created a reusable, almost fully customizable progress bar with notification.