Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature Request] add requestAnimationFrame api #438

Open
iShawnWang opened this issue Jul 15, 2024 · 3 comments
Open

[Feature Request] add requestAnimationFrame api #438

iShawnWang opened this issue Jul 15, 2024 · 3 comments

Comments

@iShawnWang
Copy link

iShawnWang commented Jul 15, 2024

It is available https://developer.mozilla.org/en-US/docs/Web/API/DedicatedWorkerGlobalScope/requestAnimationFrame

@chrisguttandin
Copy link
Owner

Hi @iShawnWang, can you please elobarte a bit what you have in mind? What would be the benefit compared to using requestAnimationFrame() on the main thread directly?

@ssjdan27
Copy link

If I had to guess, it seems like @iShawnWang wants the ability for requestAnimationFrame() to run in inactive tabs like what you have done here for the timers. If I recall correctly, requestAnimationFrame() does not run at all in inactive tabs and will completely stop until you go back to that tab. Could be of use, but I have not needed it myself.

@chrisguttandin
Copy link
Owner

Thanks for chiming in @ssjdan27.

My take is that requestAnimationFrame() is meant to run some code right before the browser renders something on the screen. When a website is not visible it will also not render anything on the screen and therefore it seems reasonable to me that requestAnimationFrame() never gets called.

If requestAnimationFrame() is used for something that doesn't render anything but should be called periodically it should probably be replaced by setTimeout() or setInterval().

But maybe there is a use case that I just haven't thought of yet. I'd be happy to be convinced otherwise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants