colpick-jQuery-Color-Picker icon indicating copy to clipboard operation
colpick-jQuery-Color-Picker copied to clipboard

onChange fires when mouse is down, even if value is not changing

Open GregWoods opened this issue 10 years ago • 5 comments

If a user is holding down the mouse button whilst moving the mouse around the color picker, the onchange event fires... unless the user is holding the mouse button down over one spot, without moving, in this case the value is not actually changing and so the event should not fire.

I can filter this out in my code, but seemed sensible to make onchange do what it is supposed to do.

GregWoods avatar May 26 '15 08:05 GregWoods

I think it's fixed in the latest version of my fork. Can you confirm that?

mrgrain avatar May 27 '15 10:05 mrgrain

Yes indeed, it is fixed. I thought I had used your fork, not sure how I got an old version.

Thanks for your work on this

GregWoods avatar May 27 '15 13:05 GregWoods

I have no idea what I was talking about. onchange still fires whenever the mouse button is held down, even if the value is not changing. I must have had my workaround in place when I closed this.

I have tried several branches, but cannot find a fix.

GregWoods avatar Jun 03 '15 14:06 GregWoods

Browser and OS please. Example code if possible. Honestly can't confirm it with the fork atm. Only fires when mouse is moved :(

mrgrain avatar Jun 03 '15 20:06 mrgrain

This is broken for me in Chrome 43.0.2357.81m Working in Firefox Working in IE11

The simplified code I'm using


            $('#example-flat').colpick({
                color:'123456',
                flat:true,
                layout:'hex',
                submit: false,
                onChange: function(hsb, hex, rgb, bySetColor) {
                        //ajax call to the api to change the colour
                        $.ajax({
                            method : "PUT",
                            url : "/api/color/" + hex,
                            success : function(data) {
                                $('#debug').val('color changed to: ' + hex);
                            }
                        });
                }
            });

GregWoods avatar Jun 04 '15 09:06 GregWoods