Open
Conversation
ThaNarie
requested changes
Apr 6, 2023
ThaNarie
requested changes
Apr 6, 2023
6a83dd7 to
af949e6
Compare
leroykorterink
approved these changes
May 15, 2023
ThaNarie
requested changes
May 31, 2023
Comment on lines
+7
to
+8
| `useAnimationLoop` hook is a wrapper around requestAnimationFrame function. This hook will execute | ||
| the passed callback function every frame. |
Member
There was a problem hiding this comment.
Suggested change
| `useAnimationLoop` hook is a wrapper around requestAnimationFrame function. This hook will execute | |
| the passed callback function every frame. | |
| `useAnimationLoop` hook is a wrapper around the `requestAnimationFrame` function. This hook will invoke | |
| the passed `callback` function every frame. |
Comment on lines
+18
to
+19
| - `callback` - function accepts `delta` parameter which represents time passed since last | ||
| invocation; |
Member
There was a problem hiding this comment.
Suggested change
| - `callback` - function accepts `delta` parameter which represents time passed since last | |
| invocation; | |
| - `callback` - a function that receives a `delta` parameter which represents time passed since last | |
| invocation, in milliseconds, as a [DOMHighResTimeStamp](https://developer.mozilla.org/en-US/docs/Web/API/DOMHighResTimeStamp) |
| const [currentTimestamp, setCurrentTimestamp] = useState(Date.now); | ||
| const [isRunning, toggleIsRunning] = useToggle(true); | ||
| useAnimationLoop(() => { | ||
| setCurrentTimestamp(Date.now); |
Member
There was a problem hiding this comment.
In this example, it might be more useful to do something (e.g. log) the delta that is passed, to better showcase the features of this hook.
| * useAnimationLoop hook is a wrapper around requestAnimationFrame method. | ||
| * This hook will execute a callback function every next frame. | ||
| * | ||
| * @param callback - callback function with @param delta which represents time passed since last invocation |
Member
There was a problem hiding this comment.
This docs (still) say delta, while the implementation (has changed?) returns the actual time.
When running an individual animationFrame, the time might be useful. When you running them in a loop, the delta is often more useful.
I don't mind also forwarding the timestamp, but I feel we should at least calculate and pass the delta.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
useAnimationLoophook is a wrapper around requestAnimationFrame function.This hook will execute the passed callback function every frame.