Permalink
Browse files

mouseup and click events now work correctly after dragging and droppi…

…ng a shape
  • Loading branch information...
1 parent 39959ed commit 17759134766835ffe4ff1a1952a8d6bd884fbd65 @ericdrowell committed Jan 29, 2013
Showing with 15 additions and 6 deletions.
  1. +5 −2 src/DragAndDrop.js
  2. +1 −1 tests/html/functionalTests.html
  3. +9 −3 tests/js/functionalTests.js
View
@@ -238,7 +238,10 @@
* @methodOf Kinetic.Node.prototype
*/
+ // listen for capturing phase so that the _endDrag method is
+ // called before the stage mouseup event is triggered in order
+ // to render the hit graph just in time to pick up the event
var html = document.getElementsByTagName('html')[0];
- html.addEventListener('mouseup', Kinetic.DD._endDrag);
- html.addEventListener('touchend', Kinetic.DD._endDrag);
+ html.addEventListener('mouseup', Kinetic.DD._endDrag, true);
+ html.addEventListener('touchend', Kinetic.DD._endDrag, true);
})();
@@ -16,7 +16,7 @@
test.run();
document.getElementsByTagName('body')[0].addEventListener('mousemove', function(evt) {
- console.log(evt.clientX + ',' + evt.clientY);
+ //console.log(evt.clientX + ',' + evt.clientY);
}, false);
};
@@ -46,7 +46,7 @@ Test.Modules.DD = {
// which can't be simulated. call _endDrag manually
Kinetic.DD._endDrag();
},
- 'test dragstart, dragmove, dragend': function(containerId) {
+ '*test dragstart, dragmove, dragend': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,
@@ -73,6 +73,7 @@ Test.Modules.DD = {
var dragStart = false;
var dragMove = false;
var dragEnd = false;
+ var mouseup = false;
circle.on('dragstart', function() {
dragStart = true;
@@ -85,8 +86,13 @@ Test.Modules.DD = {
circle.on('dragend', function() {
dragEnd = true;
// test set draggable false after drag end
- this.setDraggable(false);
+ //this.setDraggable(false);
});
+
+ circle.on('mouseup', function() {
+ console.log('mousup')
+ });
+
warn(layer.toDataURL() === dataUrls['drag circle before'], 'start data url is incorrect');
/*
* simulate drag and drop
@@ -121,7 +127,7 @@ Test.Modules.DD = {
test(dragStart, 'dragstart event was not triggered');
test(dragMove, 'dragmove event was not triggered');
test(dragEnd, 'dragend event was not triggered');
- test(!circle.getDraggable(), 'circle should no longer be draggable');
+ //test(!circle.getDraggable(), 'circle should no longer be draggable');
warn(layer.toDataURL() === dataUrls['drag circle after'], 'end data url is incorrect');
},

0 comments on commit 1775913

Please sign in to comment.