PitPik / tinyColorPicker

Tiny jQuery color picker for mobile and desktop with alpha channel
http://www.dematte.at/tinyColorPicker/
MIT License
276 stars 77 forks source link

emptying input value #90

Open catalystweb opened 3 years ago

catalystweb commented 3 years ago

I know there was an issue that was raised regarding this, but the applied fix doesn't work for me. (discussed here ) I want the user to be able to clear the value of the input, however it defaults to '#FFF'. How I fixed it was,

  1. $(_$UI).hide(_options.animationSpeed, function() { // preRender(false); _colorPicker.$trigger = null; }).off('.tcp');

  2. .on('change.tcp', function() { _color.setColor(this.value || '#FFF'); //_this.colorPicker.render(true); })

(1) The preRender function appears to setup the properties and values to initially load a picker, why its called in the hide method I don't understand ? commenting this out stopped the default values from being applied to the field when the user clicked or tabbed out of the field. (2) The render(true) property calls the preRender function which as with 1. overwrites the field value. Commenting this out stopped this, furthermore you could remove the on change handler entirely as setColor is applied during preRender and toggle functions.