simonwep / pickr

🎨 Flat, simple, multi-themed, responsive and hackable Color-Picker library. No dependencies, no jQuery. Compatible with all CSS Frameworks e.g. Bootstrap, Materialize. Supports alpha channel, rgba, hsla, hsva and more!
https://simonwep.github.io/pickr
MIT License
4.32k stars 284 forks source link

Conflict between clear and change events #311

Closed Kazem-ma79 closed 2 years ago

Kazem-ma79 commented 2 years ago

There's a problem while calling clear event, which calls change event.

When I press clear button, change event runs.

Code:

pickr.on('cancel', (instance) => {
    let request = new XMLHttpRequest();
    request.open("GET", "/off");
    request.send();
}).on('clear', (instance) => {
    let request = new XMLHttpRequest();
    request.open("GET", "/lightup");
    request.send();
}).on('change', (color) => {
    let hex = color.toHEXA();
});

Environment:

Version (see Pickr.version): 1.8.2
Used bundle (es5 or normal one): normal
Used theme (default is classic): classic
Browser-version:  Chrome 96
Operating-system:  Windows 10 - 64bit
saeednazarix commented 2 years ago

I don't think this plugin will get any updates anymore :(

I struggled a lot with changing default buttons actions and to some extent, I got the desired result, but again, in the end, there was an undesired behavior.

Finally, it forced me to add custom buttons myself and I could do whatever I wanted without any problems. Why don't you add buttons to this plugin yourself? You won't have any possible problems or undesired behaviors.

I added a video for something else but you can see my implemented buttons: https://github.com/Simonwep/pickr/issues/310

just my 2 cents:)

simonwep commented 2 years ago

This works as intended, clearing it is technically a change...