Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a color change "end" event #187

Open
fitzmode opened this issue Aug 1, 2022 · 6 comments
Open

Adding a color change "end" event #187

fitzmode opened this issue Aug 1, 2022 · 6 comments

Comments

@fitzmode
Copy link

fitzmode commented Aug 1, 2022

A common pattern in React is to have global state management. Even with debouncing, frequent updates on any moderately large global state is expensive. Would it be possible to add a changeEnd event that returns a final value based on perhaps on internal mouseup event of the different color pickers?

This would allow updating state once on user input completion.

An example use case would be - considering the color picker for the graphic design tool canva.com - where color updates are reflected in real time on elements the user is editing. This part of the problem can perhaps be handled imperatively. However, we would still need to update the state with the final value to sync it with imperatively updated values. This is where an changeEnd event would be useful.

Happy to hear feedback and if you'd be open to me working on a PR.

Thanks.

@BastianJunker
Copy link

This would be very useful for me too

@Karniej
Copy link

Karniej commented Sep 17, 2022

Good idea +1

@theashraf
Copy link

+1

1 similar comment
@mikeKlech
Copy link

+1

@mikeKlech
Copy link

mikeKlech commented Feb 3, 2023

It will be useful for undo/redo functionality. I have already implemented your color picker and it works really well, but without this functionality I have to rolling back the changes.

You can just add extra parameter to onChange event. For example

onChange(ops: {
  color: string;//HEX
  stage: 'start' | 'progress' | 'end'//start - mouseDown, progress - mouseMove, end - mouseUp
}) => void;

Thank you in advance!

@mikeKlech
Copy link

mikeKlech commented Feb 3, 2023

It will be useful for undo/redo functionality. I have already implemented your color picker and it works really well, but without this functionality I have to rolling back the changes.

You can just add extra parameter to onChange event. For example

onChange(ops: {
  color: string;//HEX
  stage: 'start' | 'progress' | 'end'//start - mouseDown, progress - mouseMove, end - mouseUp
}) => void;

Thank you in advance!

If someone looking for temporary solution. You can add mouse down\move\up(don't forget about touch events as well) events(or more easier - use react-use-gesture library) to the extra div which is wrapper for ColorPicker

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants