Update view in requestAnimationFrame

9 views
Skip to first unread message

Sašo Sabotin

unread,
Jan 16, 2017, 11:18:44 AM1/16/17
to Angular
Hi guys!

I am dealing with an issue with that window.requestAnimationFrame function. So the main thing is, I have a countdown timer where I have the percentage value decreasing from 100 to zero which is then used in the view (ngStyle for width). The thing is that view gets updated with new width only when I click (tap) wherever on the screen, which is not ok. I would like width to be decreasing all the way to zero without tapping it on the screen to update it. Does anyone have some similar issues with that method?

Thank you!

Sander Elias

unread,
Jan 16, 2017, 1:03:01 PM1/16/17
to Angular
Hi Sašo,

Try using $timer instead of setTimeout (or $interval).

Regards
Sander

Message has been deleted

Sašo Sabotin

unread,
Jan 17, 2017, 1:15:44 AM1/17/17
to Angular
As I said in the post, I am using requestAnimationFrame which has all the optimizations implemented to be well accurate.
I found the problem actually and the problem was css. Transition of width for 0.2 sec was a bottleneck. After I turned off the transition property, everything is smooth as it should be!

Thanks anyway! :)
Reply all
Reply to author
Forward
0 new messages