mouseup event not fired after moving a shape (v4.1.2)
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
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!
I solved using the "dragend" event too.
yes, dragend should work as a work around for now. I'll try and see if I can sneak this into the next release
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.
Was not able to solve this using dragend, but subscription on mouseup of the canvas placeholder DIV element helped.
ah okay thanks for the heads up. I'll have this fixed by the next version, v4.3.2. Thanks!!
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/
- You can see that the mouseup event is not fired for the shapes when dragging the shapes (as described in the first post).
- 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.
- 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.
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
Fixed! Thanks guys for all of your help. The fix will be included with the 4.3.2 release coming out this week.
Hi Eric, am I doing something wrong or did this bug just reappear? Please see example here: http://jsfiddle.net/NY4QK/10/