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

Picker does not update swatch background when model changes #79

Closed klappar closed 8 years ago

klappar commented 8 years ago

The color picker does not update the swatch background when the model changes or rebinds. After opening und closing the color picker the swatch updates and displays the right color. I guess a call to $scope.update() inside of the $scope.$watch('ngModel',...)-block would solve the problem.

ruhley commented 8 years ago

This is unfortunately because of the tinycolor library that is being used. If the format is hsl or hsv and the lightness is 100% then tinycolor will always set hue and saturation to 0.

klappar commented 8 years ago

But shouldn't the swatch background-color be updated on model rebind/change? I can only find that in the else block handling an empty/invalid color.

I'm sure I'm missing something here...

ruhley commented 8 years ago

The watch on ngModel sets the hue, saturation and lightness if the color is valid. These fields then have their own watchers that will update the positions of the selectors and the swatch background color.

ruhley commented 8 years ago

@klappar I will close this ticket, but feel free to re-open it if you manage to track down the problem. A jsfiddle or plunkr would be great to help me.