ruhley / angular-color-picker

Vanilla AngularJS Color Picker Directive with no requirement on jQuery
http://ruhley.github.io/angular-color-picker/
MIT License
166 stars 79 forks source link

Explicitly specify that saturation and lightness are percentages. If … #142

Closed jooleeunc closed 7 years ago

jooleeunc commented 7 years ago

…not, tinycolor tries to guess if a value is a percentage and sometimes ends up guessing wrong.

If you look at documentation for tinycolor, you can look at inputToRGB() method. For saturation and lightness, it calls convertToPercentage() method, and this method looks like this:

function convertToPercentage(n) {
    if (n <= 1) {
        n = (n * 100) + "%";
    }

    return n;
}

So, if we have saturation and lightness values of a very low percentage like 0.5 (i.e. half a percent), it thinks that this is not a percentage and multiplies by 100.

This pull request fixes #140 .

jooleeunc commented 7 years ago

Thanks! When do you think you will cut a new release?