Open wchargin opened 2 weeks ago
Extra tags for searching: rotation transform with extra commas and blank values / spaces, rotation transform with very small numbers.
I'm using value = Math.round(value * 100) / 100
as a workaround, but that's obviously pretty shoddy.
Which react-spring target are you using?
@react-spring/web
@react-spring/three
@react-spring/native
@react-spring/konva
@react-spring/zdog
What version of react-spring are you using?
@react-spring/web@9.7.3
What's Wrong?
I am calling
useSpring
withtransform: "rotate(...)"
where thefrom
andto
transforms are both valid, but the resulting transform that react-spring gives isrotate(0.566259767453662rotate(, , ), 2rotate(, , ), 20rotate(, , ))
, which is an invalid value that fails to render properly.To Reproduce
Download this HTML file and open it in your browser: https://gist.github.com/wchargin/0a49246fcb9792904878013c53987d1f
You'll see the following:
https://github.com/user-attachments/assets/a0b53340-35c7-4a53-8762-c909b237d05a
This HTML file draws a little speedometer needle and animates it from facing left to facing right. But when it gets to facing straight up, the animation stalls and only recovers once it's no longer animating at all:
You can set
USE_SPRING = false
to always use the "latest" transform value, which moves properly. This demonstrates that it's not an issue with the input that I'm passing touseSpring
.Tested in Firefox 130 and Chrome 128 on macOS.
Expected Behaviour
The needle should animate smoothly without crashing in the middle.
Link to repo
https://gist.github.com/wchargin/0a49246fcb9792904878013c53987d1f