News for hackers. Stuff that matters.
Re:Breaking down a ripple animation in JavaScript by fenomas on Friday August 20, 2021 @10:26PM (#28253550)
I understand that, but the answer is the same. setTimeout isn't needed as a fallback (since RAF is widely supported), and it's not better time-wise (since the code we're talking shouldn't run when the document isn't visible).

And to answer the edit, setTimeout is not more reliable than setInterval. They both fire from the same event loop, so timing-wise they're identical (apart from one recurring and the other not).

Re:Breaking down a ripple animation in JavaScript by beebeepka on Saturday August 21, 2021 @03:58AM (#28255100)
I see. You are downvoting me because you think RAF is only useful for drawing graphics in the active tab, and nothing else.

setTimeout is absolutely more reliable than setInterval. Maybe try writing a scheduler/task runner and try for yourself before coming down on people.

Re:Breaking down a ripple animation in JavaScript by fenomas on Saturday August 21, 2021 @04:46AM (#28255328)
(a) I didn't downvote you.

(b) setInterval and setTimeout fire off the same event loop; they can only occur at the same fixed times. Why do you think one is more reliable? Just repeating that it's the case doesn't convey any information.

(c) I've written various schedulers; the most recent one is `micro-game-shell` on github if you're interested.

Re:Breaking down a ripple animation in JavaScript by beebeepka on Saturday August 21, 2021 @10:23AM (#28257239)
b) I've observed different time deltas between the two on embedded and standard PC hardware. That's why I think there's a difference. Also, their behaviour has changed over the last few years, making them extremely unreliable as the user changes tabs