kode-team / codemirror-colorpicker

colorpicker with codemirror
https://colorpicker.easylogic.studio/
MIT License
137 stars 13 forks source link

Final result on close #19

Closed hcomnetworkers closed 6 years ago

hcomnetworkers commented 6 years ago

Is your feature request related to a problem? Please describe. We have a redux store to control the colors being selected. In case the color does change we do obiously change it. The current callback and onChange property do trigger on each single change. Which does trigger a lot request.

Describe the solution you'd like Having an option to get the color on close would be a solution, or an additional callback. An alternative would be to change the callback that is passed to open().

Additional context I am not sure if the current callback passed on open() and the property onChange does make sense, both trigger at the same time.

easylogic commented 6 years ago

hi @hcomnetworkers

Callback for show function and onChange property is used both.

please see below code

  if (typeof this.opt.onChange == 'function') {
     this.opt.onChange.call(this, color);
   }

    if (typeof this.colorpickerCallback == 'function') {
        this.colorpickerCallback(color);
    }        

So if you set both callback , it called many callback for 2x.

easylogic commented 6 years ago

please refer to https://easylogic.github.io/codemirror-colorpicker/1/api.html#callback-for-show-and-hide.

I added colorpicker to onHide callback.

I released v1.9.22