Adding more listeners besides onChange? #122
Replies: 4 comments 5 replies
-
I'm unsure of what you are requesting? Could you describe your use case in a bit more details? What would you need mouseup/touchend/keyup callbacks for? On which part of the color picker you would like to trigger them? |
Beta Was this translation helpful? Give feedback.
-
Sorry about this, I'll try to explain the case. I'm using Coloris to change the color of an image on the fly. The image is generated server side with PHP. Each time a new color is picked, the img src URL is updated using a javascript function. Here is a brief example:
The problem is that Coloris keeps refreshing the img src URL like crazy when you hold down the mouse button while dragging to find the right color. The console gets spammed like this: Instead of calling the function repeatedly with 'onChange', I think adding something like 'onPicked' would be very useful. I believe a color has been picked on mouse up or touch end. Please let me know your thoughts. |
Beta Was this translation helpful? Give feedback.
-
Thanks, that was exactly what I was looking for! You're a wizard. :) Now, there's just one little bug; |
Beta Was this translation helpful? Give feedback.
-
Sorry for my late reply, having busy days here. Your last example works like a dream, thank you! 🥇 Now, as usual, there's something that I didn't initially think of: I figure this is a more difficult task to solve though? |
Beta Was this translation helpful? Give feedback.
-
At the moment there's only the
onChange
function call when a new color is picked.In my specific case I need a function call if any of these occour: mouseup/touchend/keyup. In other words, I don't want to spam non-stop with onChange, but only call a function when the color has been 'properly picked'.
I have tried to create eventlisteners for this but without success since my javascript knowledge is quite limited.
Please let me know what you think about this idea.
Beta Was this translation helpful? Give feedback.
All reactions