brianpkelley / md-color-picker

Angular-Material based color picker
MIT License
254 stars 119 forks source link

Wrong mdColorAlphaChannel interpretation and options #87

Open TheWizz opened 8 years ago

TheWizz commented 8 years ago

I believe I've identified two minor bugs, for which I also include patches against the develop branch, in case you want to apply them.

  1. When specifying alphaChannel as false, I would expect the Alpha slider to NOT appear on the sliders page of the dialog (as this means to NOT provide an alpha channel value, as I interpret the docs). However, the behavior in the dialog is the opposite. I.e., the condition under which to show the Alpha slider ought to be ng-if="mdColorAlphaChannel" in mdColorPickerContainer.tpl.html.
  2. When supplying the "optional" values (i.e., those that translate into mdColorXxxx values) as an object on the scope (as passed as the value to the md-color-picker directive), those values aren't pcked up. This is how my options are applied to the scope:
    $scope.colorPickerOpts = {
        alphaChannel: false,
        history: false,
        rgb: false,
        hsl: false
    };

provided to the color picker like this:

<div label="Text Color" md-color-picker="colorPickerOpts" ng-model="block.color" ></div>

To make this work properly, I had to slightly change the logic that picks up and applies those options, as shown in the enclosed patch for mdColorPicker.js.

Please let me know if you believe I've misunderstood how something is supposed to work. If not, I hope you can accept my patch.

-JM

mdColorPickerFixes.patch.zip

brianpkelley commented 7 years ago

Options (and the plugin) are getting completely overhauled right now.

I'm leaving this open so anyone that has the same issue can more easily find the fix. Thank you for the help!