PitPik / colorPicker

Advanced javaScript color picker and color conversion / calculation (rgb, hsv, hsl, hex, cmyk, cmy, XYZ, Lab, alpha, WCAG 2.0, ...)
http://www.dematte.at/colorPicker/
MIT License
570 stars 136 forks source link

Initial set the color of the inputs #39

Closed lindell closed 8 years ago

lindell commented 8 years ago

Why are the input backgrounds not set when you initialize the color picker? You even do this manually in your examples. Seems like 90% of people usi ng this library would want that to be the default.

This code is taken from this example.

var $colors = $('input.color').colorPicker({
    customBG: '#222',
    readOnly: true,
    init: function(elm, colors) { // colors is a different instance (not connected to colorPicker)
      elm.style.backgroundColor = elm.value;
      elm.style.color = colors.rgbaMixCustom.luminance > 0.22 ? '#222' : '#ddd';
    }
  }).each(function(idx, elm) {
        // $(elm).css({'background-color': this.value})
    });
PitPik commented 8 years ago

Hi @lindell, thanks for your interest in colorPicker. I saw that you're using colorPicker on your JSBarcode demo page (wich I starred because I like). There it's probably helpful to use colorPicker as it has a javaScript only (no jQuery) implementation. Well, if you use jQuery (as you show in your example above) I'd recommend to use tinyColorPicker (https://github.com/PitPik/tinyColorPicker) instead as it's smaller and easier to use. You'd not even have to add this stuff inside an init callback. The implementations of colorPicker (both, the javaScript and jQuery version) are quite poor as I was concentrating on the color picker itself. First I had no implementations at all, but people didn't know how to use it then ;o) One day, when I have more time I will rewrite the implementations and will definitely take care of this feature (and many more that are missing right now) If you have more ideas what should be put inside the implementations, please let me know. This gives me more drive to start this earlier ;o) Thanks again Peter

lindell commented 8 years ago

The tiny color picker is exactly what I was looking for. Easy to implement and good looking (far to many color pickers are just plain ugly).

I now use it instead on the generation page

Glad you liked my barcode project :smile: Have been away from the open source dev for a while but did finally got the motivation to start again a few weeks back, hopefully you can find the drive again.