diff --git a/src/Container.js b/src/Container.js index 7fe7aa90..a6d136d0 100644 --- a/src/Container.js +++ b/src/Container.js @@ -343,6 +343,11 @@ if (hasClip) { context.restore(); } + }, + shouldDrawHit: function(canvas) { + var layer = this.getLayer(); + return ((canvas && canvas.isCache) || (layer && layer.hitGraphEnabled())) + && this.isVisible() && !Kinetic.isDragging(); } }); diff --git a/src/Group.js b/src/Group.js index f8fd625d..a877a4a4 100644 --- a/src/Group.js +++ b/src/Group.js @@ -10,10 +10,7 @@ if (type !== 'Group' && type !== 'Shape') { Kinetic.Util.error('You may only add groups and shapes to groups.'); } - }, - shouldDrawHit: function() { - return true; - }, + } }); Kinetic.Util.extend(Kinetic.Group, Kinetic.Container); diff --git a/src/Node.js b/src/Node.js index e92b3a57..d6346b9b 100644 --- a/src/Node.js +++ b/src/Node.js @@ -1518,7 +1518,7 @@ // simulate event bubbling var stopBubble = (eventType === MOUSEENTER || eventType === MOUSELEAVE) && ((compareShape && compareShape.isAncestorOf && compareShape.isAncestorOf(this)) || !!(compareShape && compareShape.isAncestorOf)); - if(evt && !evt.cancelBubble && this.parent && (!stopBubble)) { + if(evt && !evt.cancelBubble && this.parent && this.parent.isListening() && (!stopBubble)) { if(compareShape && compareShape.parent) { this._fireAndBubble.call(this.parent, eventType, evt, compareShape.parent); } diff --git a/test/unit/Node-test.js b/test/unit/Node-test.js index 9441889e..bf7a544d 100644 --- a/test/unit/Node-test.js +++ b/test/unit/Node-test.js @@ -2631,6 +2631,9 @@ suite('Node', function() { listening : true }); group.add(rect); + layer.draw(); + + showHit(layer); assert.equal(rect.isListening(), true); assert.equal(rect.shouldDrawHit(), true); @@ -2657,13 +2660,13 @@ suite('Node', function() { var top = stage.content.getBoundingClientRect().top; stage._mousedown({ - clientX: 291, - clientY: 112 + top + clientX: 150, + clientY: 75 + top }); Kinetic.DD._endDragBefore(); stage._mouseup({ - clientX: 291, - clientY: 112 + top + clientX: 150, + clientY: 75 + top }); assert.equal(rectClick, 1, 'click on rectange');