pIvan / ngx-color-picker

Pure Angular color picker library.
MIT License
96 stars 16 forks source link

Hue value not updated for colors with hue = 0 #69

Closed PierreMassanes closed 1 year ago

PierreMassanes commented 1 year ago

Hi @pIvan,

When calling setValueFrom with any color having the hue set to 0, the hue value is not updated. For example, here I selected a green color through the picker, then called setValueFrom with the color #E60303 which has a hue of 0. image You can see that the hue was not updated, but the value is the good one.

In setHueColor we have this:

    private setHueColor(color: Color) {
        if (this.hueValue && color.getHsva().hue > 0 || !this.hueValue) {
            this.hueValue = new Color().setHsva(color.getHsva().hue);
        }
    }

I think that the color.getHsva().hue > 0 is failing in that case and should be color.getHsva().hue >= 0.

What do you think ?

Thanks, Pierre

pIvan commented 1 year ago

Hi @PierreMassanes you're right, fix will be ready tomorrow :)

PierreMassanes commented 1 year ago

Thanks a lot @pIvan !

pIvan commented 1 year ago

You can try it now and let me know if it's okay, thank you! :)

PierreMassanes commented 1 year ago

I just tried it and everything is ok ! Thanks 😄