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 on 'select' event or trigger 'change' event on color reselect. #25

Open
aryoxp opened this issue May 2, 2020 · 2 comments
Open

Comments

@aryoxp
Copy link

aryoxp commented May 2, 2020

Hi, thanks for this great script there.
I use Huebee to change element's color using the 'change' event and it is working perfectly.
When I try to change another element's color using the same currently selected color, the 'change' event is not triggered.
It is of course obvious that the 'change' event is not triggered when the color does not change.
However, I need some event to be triggered when user select a color, even when there is no change in the selected color.

One more thing, when I set the color programmatically using the hueb.setColor(hex) method, the 'change' event is also not triggered. If staticOpen option is not set, the 'selection' cursor does not point to the color set even though the color being set is on the (palette) list.

Would you consider this as a feature request?
Thanks.

@desandro
Copy link
Member

You can add a duck punch for a new event

let setSwatch = Huebee.prototype.setSwatch;
Huebee.prototype.setSwatch = function( color ) {
  setSwatch.apply( this, arguments );
  this.emitEvent( 'set', [ swatch.color, swatch.hue, swatch.sat, swatch.lum ] );
};

@adambg
Copy link

adambg commented May 13, 2020 via email

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

No branches or pull requests

3 participants