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

Add changeSource parameter to instance object passed on 'change' event. #245

Closed dmarman closed 3 years ago

dmarman commented 4 years ago

Based on this issue.

The 'change' event coming from the preview fires many times per second. This doesn't allow to add an event listener that takes long to run >30ms, otherwise the preview gets blocked. So any heavy calculation has to go to 'changestop' event and only light calculations on 'change'. The problem is that 'changestop' won't fire from the input, so I cannot fire any heavy calculation when the user changes the input.

Adding extra events like 'inputChange', 'previewChange' or 'swatchChange' feels like duplicating functionality. Adding an extra parameter to the event callback will break things since it will look like (color, changeSource, instance) and the instance parameter would change from the second to the third position.

So the fastest and non-breaking solution was adding an extra property to pickr

I also changed the dev url to the current one. localhost:8080 doesn't work anymore.

simonwep commented 3 years ago

Thank you for your efforts, as in #193 I'll fire changestop on user-input too and add a source-property to the eventy. Adding another property is too specific for a single use case and might be confusing.