barvian / number-flow

A React component to transition, format, and localize numbers.
https://number-flow.barvian.me
MIT License
2.73k stars 54 forks source link

[Feature] Color animation option for increasing and decreasing numbers #6

Closed sazzouz closed 1 month ago

sazzouz commented 1 month ago

Super package. I have a feature request for color animation options when the number goes up or down. For example, in financial applications it can be useful to show a temporary fading red animation as the price of something goes down, and green when the price goes up.

barvian commented 1 month ago

Hi! Would something like this work for your use case?

sazzouz commented 1 month ago

Thanks for the quick response, this is definitely a great start that I could work with. I'm trying to implement it so that on load, you have the color change during the animation of the numbers, to quickly signal to the user of an increase or a decrease, which isn't immediately obvious with rolling numbers, and then after a suitable delay it transitions back to the normal text color. This is so that you are not left with it being red or green indefinitely which can be overly negative or positive.

A common place where you see this is on NFT marketplaces like OpenSea where the floor price changes, you have an animation similar to this package with regards to the numbers, but also a temporary color change, before returning back.

barvian commented 1 month ago

No problem. I think something like this might work better then.

sazzouz commented 1 month ago

Thank you so much, this is precisely what I was describing! And all implemented without any new additions to the lib. Superb