zefoy / ngx-color-picker

Color picker widget for the Angular (version 2 and newer)
MIT License
454 stars 142 forks source link

feature: allow cpAlphaChannel to be changed after initialization #357

Closed ExpiviRick closed 3 months ago

ExpiviRick commented 5 months ago

PR Type

What kind of change does this PR introduce?

What is the current behavior?

Opening the color picker dialog will use the initial cpAlphaChannel value. Assigning it to a variable will not work.

Example:

<input [value]="color"
       [style.background]="color"
       [cpAlphaChannel]="alphaEnabled ? 'always' : 'disabled'"
       [cpOutputFormat]="'hex'"
       [(colorPicker)]="color"/>

What is the new behavior?

The color picker dialog will update its cpAlphaChannel before opening. This will make the cpAlphaChannel option more reactive. This allows the color picker to be used with a dropdown / checkbox which decides whether alpha should be enabled/disabled (on the same page).