timothypratley / reanimated

An animation library for Reagent (ClojureScript)
250 stars 14 forks source link

Spring doesn't work with small values #8

Closed rafd closed 8 years ago

rafd commented 8 years ago

I was trying to use spring to transition a value from 0 to 0.1, which in other parts of the application is multiplied by 100. However, because spring uses small to determine if to animate or just stop at the final value, and the small threshold is absolute (currently 0.1), it makes using spring with small values infeasible (because it doesn't transition, just immediately jumps to the end).

I was able to make it work by going from 0 to 100 instead, but, I think there could be general solution.

Perhaps instead of an absolute threshold, the threshold could be a percent of the difference between the initial and final value (ex. 1%, so for 0 to 100, it would be 1; and for 0 to 0.1 it would be 0.01).

Or, perhaps there is a better approach than absolute or percentage based.

Thoughts?

I'd be willing to do figure it out and do a PR.

timothypratley commented 8 years ago

I like the percentage idea! Thanks for pointing out the issue, I hadn't considered that. PR is very welcome if you have time.

timothypratley commented 8 years ago

@rafd are you planning on submitting a PR for this? If so I'd like to include it so that you get attribution. If this has dropped off your radar, no problem, I can make the change.

rafd commented 8 years ago

I've been traveling for the past month and haven't been able to get to it. Feel free to make the change.

timothypratley commented 8 years ago

@rafd Ok, I've changed it to use % as you suggested, new jar is out [reanimated "0.4.0"] Note that the package name has changed from [timothypratley/reanimated "0.3.0"] to just 'reanimated'