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

useSpring chokes under load #238

Closed
J-Sek opened this issue Oct 13, 2024 · 1 comment
Closed

useSpring chokes under load #238

J-Sek opened this issue Oct 13, 2024 · 1 comment

Comments

@J-Sek
Copy link

J-Sek commented Oct 13, 2024

System info

- Operating System: Linux
- Node Version:     v18.20.3
- Nuxt Version:     3.13.0
- CLI Version:      3.13.1
- Nitro Version:    2.9.7
- Package Manager:  [email protected]
- User Config:      modules
- Runtime Modules:  @nuxtjs/[email protected]

Reproduction

Circle follows the mouse coordinates only if I move very slowly

demo


Edit: I managed to get somewhat decent result with transition: all 0.1s linear on circle and bounce at least 1.0, but it is far from perfect.

Describe the bug

But despite the best efforts it only works if I throttle set(...) calls with delay of at least the spring duration which defeats the goal of this code. When throttle is low (just enough to avoid stressing the browser... maybe it should not be necessary) with regular mouse movements, the coordinates get null values.

Additional context

I was looking for a way to reproduce spring effect I can see in Svelte tutorial.

@J-Sek
Copy link
Author

J-Sek commented Oct 13, 2024

Ok, I think I get it... the parameters copied from example in docs (bounce and duration) are actually quite uncommon for spring animation. Any of the following helps resolve the issue:

  • no options at all
  • use any of the following: stiffness, damping, or mass (they seem to make the algorithm ignore both duration and bounce)

Fixed demo uses all three to get the closest match to the example from Svelte.

@J-Sek J-Sek closed this as completed Oct 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant