maxs15 / react-native-spinkit

A collection of animated loading indicators for React Native
MIT License
2.36k stars 300 forks source link

Added support for colours with alpha values. #5

Closed mpretty-cyro closed 8 years ago

mpretty-cyro commented 8 years ago

Currently if you set a colour with a hex value it will display the wrong colour, this adds support for colours with alpha values.

mpretty-cyro commented 8 years ago

@maxs15 Since the change is so minor I'm hoping this can be merged fairly quickly.

maxs15 commented 8 years ago

hey @mpretty-homepass, Why didn't you use the style opacity property ?

mpretty-cyro commented 8 years ago

@maxs15 When it comes to animations or general opacity then I probably would use the style's opacity property, but the case I'm using is applying a global theme which may actually include the opacity in the hex value (having to pass through multiple values to define a global 'primary colour' would be inconvenient).

You could also just ignore the opacity in the hex (currently if you pass it through it will render as an incorrect colour which I initially thought was a bug before I looked in to what it was doing) - this way when a user passes through a hex value which includes opacity, it should be fairly obvious that the opacity part is being ignored.

maxs15 commented 8 years ago

Ok fair reason, I was just curious.. I'll merge your PR, thanks for the contribution

mpretty-cyro commented 8 years ago

@maxs15 No problem, you have every right to ask why. Here is an example of an issue I ran in to the first time I used SpinKit - I set a primary theme colour of '#4D9E02FF' (it enforces no opacity on the colour) and the following occurred:

incorrect

Whereas the colour should be:

correct colour

Just want to ensure users don't run in to the same issue in the future. Another expansion to this would probably be to add support for 3 char hex values (ie. '#F11' becomes '#F11F11'), since it is supported by React Native.

maxs15 commented 8 years ago

I see the issue, thanks for this nice and colorful explanation, if you need any further enhancements I'll always accept any PR :) Your fix is now available in the new version 0.0.7 !

mpretty-cyro commented 8 years ago

Awesome, thanks for that :)