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

perf: use performance.now and RAF callback argument (time) for useRaf. #2215

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SCG82
Copy link

@SCG82 SCG82 commented Nov 6, 2021

Description

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as before)

Checklist

  • Read the Contributing Guide
  • Perform a code self-review
  • Comment the code, particularly in hard-to-understand areas
  • Add documentation
  • Add hook's story at Storybook
  • Cover changes with tests
  • Ensure the test suite passes (yarn test)
  • Provide 100% tests coverage
  • Make sure code lints (yarn lint). Fix it with yarn lint:fix in case of failure.
  • Make sure types are fine (yarn lint:types).

@@ -22,7 +21,7 @@ const useRaf = (ms: number = 1e12, delay: number = 0): number => {
cancelAnimationFrame(raf);
set(1);
}, ms);
start = Date.now();
start = performance.now();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about keeping by default the original behavior, but allowing the user to overwrite it?

Suggested change
start = performance.now();
start = now();

where

const useRaf = (ms: number = 1e12, delay: number = 0, now = Date.now): number => {

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To allow configuration of the starting time? Isn't that what the delay is for?

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

Successfully merging this pull request may close these issues.

2 participants