KineticJS icon indicating copy to clipboard operation
KineticJS copied to clipboard

mouseup event not fired after moving a shape (v4.1.2)

Open ericmandel opened this issue 13 years ago • 10 comments

Dear Eric,

In v4.1.2, a mousedown event is fired when clicking in a shape, as expected, but after moving the shape, the mouseup event is not fired. This worked in 4.0.1.

This is easily seen by modifying the tutorial:

http://www.html5canvastutorials.com/kineticjs/html5-canvas-drag-and-drop-events-tutorial/

Change the dragend event handler to a mouseup event handler (and perhaps the dragstart handler to a mousedown handler to maintain symmetry):

  box.on('mousedown', function() {
    writeMessage(messageLayer, 'mousedown');
  });
  box.on('mouseup', function() {
    writeMessage(messageLayer, 'mouseup');
  });

Click inside the shape, move, unclick: you will see the dragstart (or mousedown) message, but not the mouseup message.

If you click and unclick inside the shape without moving, you will see both the mousedown and mouseup message.

Regards,

Eric

ericmandel avatar Dec 12 '12 22:12 ericmandel

ah, this is because the hit graph is no longer redrawn during drag and drop operations to improve performance. Will have to put some thought into this. Thanks!

ericdrowell avatar Dec 13 '12 08:12 ericdrowell

I solved using the "dragend" event too.

fbrussa avatar Dec 20 '12 21:12 fbrussa

yes, dragend should work as a work around for now. I'll try and see if I can sneak this into the next release

ericdrowell avatar Dec 20 '12 21:12 ericdrowell

I commented this in other issue but another problem is that if your drag ends so that the cursor is above a group/shape that is under the dragged element (in z-index) you get a mouseup event for the lower not dragged element which is very confusing too. You can test this with http://jsfiddle.net/SWj9m/3/ and look the javascript console for events text. So I had to refractor my code to use dragend only because one can not trust the mouseup event to be correct.

hakhak avatar Dec 22 '12 13:12 hakhak

Was not able to solve this using dragend, but subscription on mouseup of the canvas placeholder DIV element helped.

docusync avatar Jan 16 '13 01:01 docusync

ah okay thanks for the heads up. I'll have this fixed by the next version, v4.3.2. Thanks!!

ericdrowell avatar Jan 16 '13 01:01 ericdrowell

I have created a very simple fiddle to see what is happening, because this prevents me to upgrade to more recent versions : http://jsfiddle.net/2N7CP/3/

  1. You can see that the mouseup event is not fired for the shapes when dragging the shapes (as described in the first post).
  2. Drag and drop the blue rect over the yellow rect: "you get a mouseup event for the lower not dragged element" as noted by hakhak.
  3. In some special cases shapes stays on the dragLayer after dragging: a. Start dragging the yellow rect b. Move the mouse cursor outside the canvas and release the mouse button c. Move back the mouse cursor (and therefore the yellow rect) over the blue rect (mouse button is still up) and click: the yellow rect disappears. d. Start dragging the blue rect: the yellow rect appears while you are dragging the blue rect. Hope this very simple fiddle helps to fix/test these issues.

tomg7 avatar Jan 16 '13 14:01 tomg7

Thanks! As i mentioned before, the problem is just that the hit graph doesn't redraw during drag and drop, so when the mouseup event triggers, the hit graph rendering isn't there to pick up the event. The fix should be pretty easy, and will be in the v4.3.2 release sometime this week.

Hang in there,

Eric

ericdrowell avatar Feb 04 '13 06:02 ericdrowell

Fixed! Thanks guys for all of your help. The fix will be included with the 4.3.2 release coming out this week.

ericdrowell avatar Feb 05 '13 18:02 ericdrowell

Hi Eric, am I doing something wrong or did this bug just reappear? Please see example here: http://jsfiddle.net/NY4QK/10/

djfm avatar Sep 07 '13 19:09 djfm