chenglou / react-motion

A spring that solves your animation problems.
MIT License
21.69k stars 1.16k forks source link

Continously rotating without jumps between tours #608

Open korbav opened 3 years ago

korbav commented 3 years ago

I'm trying to achieve a very simple thing, rotating a square continuously without a jump between 2 tours. I want to keep control of the position and therefore I don't want to use the loop property available in the different hooks.

I created a codesandbox to explain the current situation : https://codesandbox.io/s/twilight-http-l0jm0?file=/src/App.js

As you can see when it goes forward 360 degrees, it's animating all the way back to go to 0. I suppose this is the expected behaviour. Thus, my question is, is there any way to smoothly animate between 2 rotation tours instead of animating all the way back?

Thanks in advance!

InterstellarMario commented 2 years ago

(this.state.currentRotationValueInDegrees + 10) instead of (this.state.currentRotationValueInDegrees + 10) % 360

theformer commented 2 years ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。

korbav commented 2 years ago

(this.state.currentRotationValueInDegrees + 10) instead of (this.state.currentRotationValueInDegrees + 10) % 360

That works but that has the potential to lead soon or later to a Javascript exception caused by the MAX_SAFE_INTEGER limit reached.

theformer commented 2 years ago

这是来自QQ邮箱的假期自动回复邮件。   您好,我最近正在休假中,无法亲自回复您的邮件。我将在假期结束后,尽快给您回复。