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

pickr.on("change") #193

Closed
bsastregx opened this issue Feb 7, 2020 · 5 comments
Closed

pickr.on("change") #193

bsastregx opened this issue Feb 7, 2020 · 5 comments
Assignees
Labels
improvement Something could be improved question Further information is requested

Comments

@bsastregx
Copy link

Hi!
Is it possible to know if pickr.on("change") was submitted by direct handling the pickr color window, or, on the contrary, by changing the value on the input?

Thanks!

Version (see Pickr.version):
Used bundle (es5 or normal one):
Used theme (default is classic): 
Browser-version:  
Operating-system:  
@simonwep
Copy link
Owner

simonwep commented Feb 7, 2020

The change event gets fired immediatly if:

  1. The user changed the input-value and the value is valid (related line in source).
  2. The user clicks one of the color swatches (see related line in addSwatch).
  3. The user used the controls to manipulate the value wherby _updateOutput (internal function) will be called.

Not that change won't get fired when the user manually edits the value since _recalc is false in this case to prevent any kind of double-calculation. Or pickr is not initialized yet.

@simonwep simonwep added the question Further information is requested label Feb 7, 2020
@simonwep
Copy link
Owner

simonwep commented Mar 6, 2020

Closed due inactivity.

@simonwep simonwep closed this as completed Mar 6, 2020
@dmarman
Copy link

dmarman commented Aug 28, 2020

I think a specific event for input should be fired. Another possibility is to add a changeSource item in the instance object with the source that fired the event like: changeSource: 'input', changeSource: 'preview'.

Why?
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.

Possible solutions

  • Fire also 'changestop' after user changes input.
  • Add item on the instance object with the change source: input or preview.
  • Add specific event for input

@simonwep
Copy link
Owner

simonwep commented Dec 5, 2020

@dmarman The only thing I'd do is fire changestop after the user edited the color manually using the input field. Adding a changeSource property would raise confusion and seems to be too case-specific.

@bsastregx I could possibly add a source property to both events for where the events came from.

@simonwep simonwep reopened this Dec 5, 2020
@simonwep simonwep added the improvement Something could be improved label Dec 5, 2020
@simonwep
Copy link
Owner

simonwep commented Dec 5, 2020

Fixed in a056616. I'll publish a new version today.

@simonwep simonwep closed this as completed Dec 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Something could be improved question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants