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

[feature] implement a clickoutside event #266

Closed
virgo79 opened this issue Nov 28, 2014 · 5 comments
Closed

[feature] implement a clickoutside event #266

virgo79 opened this issue Nov 28, 2014 · 5 comments

Comments

@virgo79
Copy link

virgo79 commented Nov 28, 2014

I think it would be very useful knowing how a user is closing a color picker.
he is clicking outside the colorpicker or he is hitting the cancel button?
I wondered if is there a way to obtain this without implementing a clickoutside event.
thank you very much in advance.

@bgrins
Copy link
Owner

bgrins commented Dec 9, 2014

Does the clickoutFiresChange option work for you? https://bgrins.github.io/spectrum/#options-clickoutFiresChange. In this case the clickout will just let the color value stay as-is, so you may not need to see the event?

@virgo79
Copy link
Author

virgo79 commented Dec 9, 2014

ClickoutFiresChange works great, but it not solve the problem. A generic clickoutside event would give more flexibility, as you can know how a user is closing the color picker and you can implement an event handler to better customize the user experience. Concerning how I'm using spectrum, it's a bit tricky because I've to force the trigger change of the input field inside the "move" callback handler. Due to this triggering I lose the value as-was before opening the color picker. A clickoutside event will give me the ability to restore a value previously stored with the open event.
Sorry for the tricky response, anyway I think could be an added value having a clickoutside event.
Thank you very much in advance!

@bgrins
Copy link
Owner

bgrins commented Dec 9, 2014

Concerning how I'm using spectrum, it's a bit tricky because I've to force the trigger change of the input field inside the "move" callback handler

It sounds like what would help is something like #173, where this would be an option (also related - #250). Getting all of these events tamed and unified has proven to be tricky.

In theory we could add an option to the hide() function to notify that the cancel button is clicked and send this along in the event, but that would add even more cases to handle for the previous issues. I can't think of a fix that won't add extra complexity off the top of my head - I think it would be preferable to tack #173, since that will resolve quite a few open and related issues, and make your use case much easier.

There are a variety of ways you could work around this for now - one would be to digging into the spectrum("container").find(".sp-cancel") and binding an event on mousedown to set a flag that this it is being clicked, then clear that flag on document mouseup.

@virgo79
Copy link
Author

virgo79 commented Dec 9, 2014

Ok, Thanks for the suggestion.I will try to find a workaround.

@virgo79
Copy link
Author

virgo79 commented Dec 10, 2014

Hey Brian,
I wish to thank you very much!
Following your suggestion, I found a good solution to my problem.

@virgo79 virgo79 closed this as completed Dec 10, 2014
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

2 participants