-
Notifications
You must be signed in to change notification settings - Fork 145
feat(raf): add frameloop utils. #824
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
base: main
Are you sure you want to change the base?
feat(raf): add frameloop utils. #824
Conversation
- Added `useFrameloop` util to use unified request animation frame calls. - Added `createScheduledFrameloop` to handle request animation frame from external sources. - Fixed `createRAF` cleanup for id `0` by using `null` instead.
|
| } | ||
|
|
||
| /** | ||
| * Returns an advanced primitive factory function (that has an API similar to `createRAF`) to handle multiple animation frame callbacks in a single batched `requestAnimationFrame`, avoiding the overhead of scheduling multiple animation frames outside of a batch and making them all sync on the same delta. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The explanation is way too complex. "A version of createRAF that batches multiple frames within the same render cycle instead of skipping them ."
| * | ||
| * The idea behind this is for more complex use cases, where you need scheduling and want to avoid potential issues arising from running more than one `requestAnimationFrame`. | ||
| * | ||
| * @see https://github.com/solidjs-community/solid-primitives/tree/main/packages/raf#createScheduledFrameloop |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You seem to have forgotten to update the README.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sorry for that!
| automatic?: MaybeAccessor<boolean>, | ||
| ) => [ | ||
| queued: Accessor<boolean>, | ||
| queue: VoidFunction, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that I generally dislike this addition, but why not extract the queue logic into a separate primitive that can also be used with the normal createRAF?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could I get some guidance on how that would be structured? Do you propose adding the queue logic as a separate create helper?
useFramelooputil to use unified request animation frame calls.createScheduledFrameloopto handle request animation frame from external sources.createRAFcleanup for id0by usingnullinstead.Addresses this proposal #822.