React-color: document the onChangeComplete delay and make it configurable

Created on 11 Jun 2018  路  6Comments  路  Source: casesandberg/react-color

I couldn't find any explanation in the documentation as to what onChangeComplete actually does. The code reveals that it is a hardcoded debounce with 100ms.

I suggest:

  1. Document the behavior
  2. Make the 100ms configurable
enhancement help wanted

Most helpful comment

There is an event missing. Most controls have onScroll, onChange, onChangeComplete. Here we have only two, and debouncing won't solve all issues. As we need to keep backward compatibility, I would suggest adding another event onColorSelected when the mouse button is released.

onChangeComplete is definitely named wrong, as nothing, ever, is complete while the user is still holding the mouse button down.

All 6 comments

This makes a lot of sense

For sliders and color grids, It would be great if the onChangeComplete was only fired when the user released the mouse, not when they stopped moving the mouse. For an undo system, i want to undo when the user releases the mouse, not when they stop dragging

There is an event missing. Most controls have onScroll, onChange, onChangeComplete. Here we have only two, and debouncing won't solve all issues. As we need to keep backward compatibility, I would suggest adding another event onColorSelected when the mouse button is released.

onChangeComplete is definitely named wrong, as nothing, ever, is complete while the user is still holding the mouse button down.

I did not understand the purpose of onChangeComplete. As it was mentioned, it doesn't make sense for this to fire at all while i'm still dragging some slider. Once i release the button, and am done dragging, only then should the change be complete.

It makes sense. We need one event which fires while dragging (imagine you want to reflect the current color in an outside element while still dragging), and one when released (for example for permanently saving the result).

onChangeComplete should probably be onChangeCommitted or something along those lines. Yes, one is needed to fire as we are moving, eg. using requestAnimationFrame the other once we commit the change eg. mouseup.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

louh picture louh  路  4Comments

japgolly picture japgolly  路  5Comments

imsheng picture imsheng  路  6Comments

jimmylinh picture jimmylinh  路  4Comments

stevenxxiu picture stevenxxiu  路  6Comments