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

Improvement suggestion: useTimeout #311

Open
janwirth opened this issue Apr 27, 2023 · 1 comment
Open

Improvement suggestion: useTimeout #311

janwirth opened this issue Apr 27, 2023 · 1 comment
Labels
enhancement Improvements

Comments

@janwirth
Copy link

User story: I want to use useTimeout in order to nudge the user while they are looking at my page.

Problem: If the timeout elapses while the user is looking at another tab, they will miss the nudge.

It would be very nice if useTimeout had an option / variant that 'pauses' the timeout if the window is not focused.

This would require

  1. keeping the started timestamp
  2. clearing the timeout on window defocus and keep the elapsed time
  3. when the window is focused, set a new timeout which is the original timeout minus the elapsed time
  4. consider a scenario with multiple blur.
@stevebeauge
Copy link

Hello @janwirth

maybe this can help: https://codesandbox.io/s/wizardly-minsky-39c9nf?file=/src/App.tsx

@juliencrn I consider submitting a PR to integrate my work if you think it is worth it.

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

No branches or pull requests

3 participants