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: The throttle function should remove the default 1000 milliseconds to support the use of requestAnimationFrame #2331

Closed
zhe-he opened this issue Sep 26, 2023 · 3 comments · Fixed by #2332
Labels

Comments

@zhe-he
Copy link

zhe-he commented Sep 26, 2023

Hello, I have a requirement in my React project to throttle using requestAnimationFrame. I noticed that lodash natively supports it, but ahooks has added extra logic to set a default time of 1000 milliseconds. Here are the links to the two relevant source code sections:

  1. Lodash throttle source code
  2. ahooks source code
@crazylxr
Copy link
Collaborator

你可以把 wait 设置为 0 来实现你的需求

@liuyib
Copy link
Collaborator

liuyib commented Feb 27, 2024

https://github.com/lodash/lodash/blob/main/src/debounce.ts#L77-L78

image

@crazylxr 见哥,这里 wait 设置 0 恰好是绕过 requestAnimationFrame,需要 ahooks 支持用户设置 wait 为 undefined 来启用 requestAnimationFrame 的,你再看下呢~

@liuyib
Copy link
Collaborator

liuyib commented Apr 23, 2024

solved: #2332

@liuyib liuyib closed this as completed Apr 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants