omgovich / react-colorful

🎨 A tiny (2,8 KB) color picker component for React and Preact apps
https://omgovich.github.io/react-colorful
MIT License
3.19k stars 100 forks source link

Fix RGBA calc error when change alpha #184

Open t-hamano opened 2 years ago

t-hamano commented 2 years ago

Fix: #163

I believe this error is due to an unavoidable rounding error in the process of inter-converting RGB and HSV with integer values. However, I thought this error would be avoided by retaining the cached RGB values when the alpha value is changed.

I don't know if this change is sufficient, but it appears to have worked correctly for me. I hope this will be helpful to fix the problem.

t-hamano commented 2 years ago

Sorry I didn't check carefully enough, but I noticed that package size limit has exceeded by few bytes. At the moment I can't think of a solution other than raising the size limit, but I would be happy to help if there is anything I can do.

t-hamano commented 2 years ago

I have changed it so that it can update the alpha value for any type of cache.current.color.

I think the components are working correctly but I couldn't solve the type error 😅 Do you have any good solution?

t-hamano commented 2 years ago

✅ I was able to fix the type error. ✅ Didn't exceed size limit (thanks to you raising the size limit) ✅ Merged the latest master and added updateAlpha to HexAlphaColorPicker

Hope this PR helps!

abezydar commented 1 year ago

I'd like to add my vote to getting this merged if possible. I'm running into an issue where the color starts out as 239,239,239 and then is rounded to 240,240,240 when changing the alpha slider. I'm hoping this will fix the issue.