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

[NFR] Allow custom callbacks on dragStart/dragStop #160

Closed
temuri416 opened this issue Jan 10, 2014 · 9 comments
Closed

[NFR] Allow custom callbacks on dragStart/dragStop #160

temuri416 opened this issue Jan 10, 2014 · 9 comments

Comments

@temuri416
Copy link

I would like to be able to supply custom callback for dragStart/dragStop events.

Thank you!

@temuri416
Copy link
Author

Also, would it be possible for those events to fire "change" method?

@bgrins
Copy link
Owner

bgrins commented Jan 13, 2014

What is the use case? Cancelling the drag event - or do you just want to listen to when it happens?

@temuri416
Copy link
Author

Here's the usecase.

  1. I have a color picker similar to your "Flat" example at http://bgrins.github.io/spectrum/
  2. I have hidden/disabled "Choose" button
  3. There is no form input to provide colors via copy/paste, just a DIV displaying current color value
  4. I want the user to be able to drag the color selector and fire AJAX call to store the value immediately after 'onMouseUp' event.

The only problem is that if you release mouse button while outside the color selection are, the 'onMouseUp' does not trigger.

In other words, I need to get the execution control when mouse button is released outside color selection area to be able to fire AJAX call with currently selected color.

Hope that explains it.

Thanks!

@bgrins
Copy link
Owner

bgrins commented Jan 14, 2014

So, if we added a dragstop event that you could listen to, that would allow you to fire your AJAX call off when the user finishes the change, correct? Ideally your code shouldn't have to deal directly with mouseup events (since this could be touchend in some cases, for instance)

@temuri416
Copy link
Author

  1. yes, that'd solve my problem
  2. I was doing mouseup only because I had no choice :)

Thanks for the great widget!

@bgrins
Copy link
Owner

bgrins commented Jan 17, 2014

OK, this should be working now if you grab latest from https://github.com/bgrins/spectrum/blob/master/spectrum.js

@bgrins bgrins closed this as completed Jan 17, 2014
@bgrins
Copy link
Owner

bgrins commented Jan 17, 2014

Using code like this:

$(element).on("dragstart.spectrum", function(e, color) {

}

$(element).on("dragstop.spectrum", function(e, color) {

}

@temuri416
Copy link
Author

Works as expected, thank you.

@kotmatpockuh
Copy link

@temuri416 @bgrins please take a look: #352

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

3 participants