mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 18:27:58 +08:00
improve shouldDrawHit behaviour
This commit is contained in:
@@ -343,6 +343,11 @@
|
|||||||
if (hasClip) {
|
if (hasClip) {
|
||||||
context.restore();
|
context.restore();
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
shouldDrawHit: function(canvas) {
|
||||||
|
var layer = this.getLayer();
|
||||||
|
return ((canvas && canvas.isCache) || (layer && layer.hitGraphEnabled()))
|
||||||
|
&& this.isVisible() && !Kinetic.isDragging();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@@ -10,10 +10,7 @@
|
|||||||
if (type !== 'Group' && type !== 'Shape') {
|
if (type !== 'Group' && type !== 'Shape') {
|
||||||
Kinetic.Util.error('You may only add groups and shapes to groups.');
|
Kinetic.Util.error('You may only add groups and shapes to groups.');
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
shouldDrawHit: function() {
|
|
||||||
return true;
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
Kinetic.Util.extend(Kinetic.Group, Kinetic.Container);
|
Kinetic.Util.extend(Kinetic.Group, Kinetic.Container);
|
||||||
|
|
||||||
|
@@ -1518,7 +1518,7 @@
|
|||||||
|
|
||||||
// simulate event bubbling
|
// simulate event bubbling
|
||||||
var stopBubble = (eventType === MOUSEENTER || eventType === MOUSELEAVE) && ((compareShape && compareShape.isAncestorOf && compareShape.isAncestorOf(this)) || !!(compareShape && compareShape.isAncestorOf));
|
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) {
|
if(compareShape && compareShape.parent) {
|
||||||
this._fireAndBubble.call(this.parent, eventType, evt, compareShape.parent);
|
this._fireAndBubble.call(this.parent, eventType, evt, compareShape.parent);
|
||||||
}
|
}
|
||||||
|
@@ -2631,6 +2631,9 @@ suite('Node', function() {
|
|||||||
listening : true
|
listening : true
|
||||||
});
|
});
|
||||||
group.add(rect);
|
group.add(rect);
|
||||||
|
layer.draw();
|
||||||
|
|
||||||
|
showHit(layer);
|
||||||
|
|
||||||
assert.equal(rect.isListening(), true);
|
assert.equal(rect.isListening(), true);
|
||||||
assert.equal(rect.shouldDrawHit(), true);
|
assert.equal(rect.shouldDrawHit(), true);
|
||||||
@@ -2657,13 +2660,13 @@ suite('Node', function() {
|
|||||||
|
|
||||||
var top = stage.content.getBoundingClientRect().top;
|
var top = stage.content.getBoundingClientRect().top;
|
||||||
stage._mousedown({
|
stage._mousedown({
|
||||||
clientX: 291,
|
clientX: 150,
|
||||||
clientY: 112 + top
|
clientY: 75 + top
|
||||||
});
|
});
|
||||||
Kinetic.DD._endDragBefore();
|
Kinetic.DD._endDragBefore();
|
||||||
stage._mouseup({
|
stage._mouseup({
|
||||||
clientX: 291,
|
clientX: 150,
|
||||||
clientY: 112 + top
|
clientY: 75 + top
|
||||||
});
|
});
|
||||||
|
|
||||||
assert.equal(rectClick, 1, 'click on rectange');
|
assert.equal(rectClick, 1, 'click on rectange');
|
||||||
|
Reference in New Issue
Block a user