question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Custom inertial spring used to work on canary.808.17, but not in rc3

See original GitHub issue

🐛 Bug Report

I previously implemented a rubberbanding drag slider with react-use-gesture and react-spring that used to work quite well based upon dbusmut’s initial code for something similar. This used to work with the new decay and initial velocity functions introduced in earlier versions of 9 quite well. It has now stopped working after updating to rc3. It seems to be something to do with triggering a state update at the same time as updating the spring value which seems to affect the onchange prop on the spring from executing as expected.

The repro should display the issue, toggling the state update before flinging the drag handle should highlight the difference in the way react-spring reacts.

To Reproduce

Try updating state at the end of a drag event from react-use-gesture, whilst updating a spring with decay enabled with an initial velocity.

Expected behavior

The code used to work before rc3, it should limit the animation of the drag handle to its confines whilst allowing rubberbanding whilst being dragged.

Link to repro (highly encouraged)

https://codesandbox.io/s/react-spring-rc3-updating-onchange-within-custom-hook-yy8f7?file=/src/index.js

Environment

  • react-spring v9.0.0-rc.3
  • react v16.8.6

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
joshuaelliscommented, Apr 27, 2021

💃🏻

0reactions
HQ92commented, Apr 27, 2021

This works perfectly for me - https://codesandbox.io/s/inertial-spring-react-spring-v920-beta0-kyq3d, it’s not doing the jumping to the end value, ignoring the decay animation, at the end anymore. So 10/10 from me 😋

Read more comments on GitHub >

github_iconTop Results From Across the Web

Custom inertial spring used to work on canary.808.17, but not ...
It has now stopped working after updating to rc3. It seems to be something to do with triggering a state update at the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found