mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
intersects with shadow. close #1027
This commit is contained in:
parent
362bcf9efc
commit
a4ea6a65a5
@ -1522,6 +1522,7 @@ var Kinetic = {};
|
||||
Kinetic.Canvas.call(this, conf);
|
||||
this.context = new Kinetic.HitContext(this);
|
||||
this.setSize(width, height);
|
||||
this.hitCanvas = true;
|
||||
};
|
||||
Kinetic.Util.extend(Kinetic.HitCanvas, Kinetic.Canvas);
|
||||
|
||||
@ -7913,7 +7914,7 @@ var Kinetic = {};
|
||||
drawFunc.call(this, bufferContext);
|
||||
bufferContext.restore();
|
||||
|
||||
if (hasShadow) {
|
||||
if (hasShadow && !canvas.hitCanvas) {
|
||||
context.save();
|
||||
context._applyShadow(this);
|
||||
context.drawImage(bufferCanvas._canvas, 0, 0);
|
||||
@ -7934,7 +7935,7 @@ var Kinetic = {};
|
||||
context.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
|
||||
}
|
||||
|
||||
if (hasShadow) {
|
||||
if (hasShadow && !canvas.hitCanvas) {
|
||||
context.save();
|
||||
context._applyShadow(this);
|
||||
drawFunc.call(this, context);
|
||||
|
4
kinetic.min.js
vendored
4
kinetic.min.js
vendored
File diff suppressed because one or more lines are too long
@ -203,6 +203,7 @@
|
||||
Kinetic.Canvas.call(this, conf);
|
||||
this.context = new Kinetic.HitContext(this);
|
||||
this.setSize(width, height);
|
||||
this.hitCanvas = true;
|
||||
};
|
||||
Kinetic.Util.extend(Kinetic.HitCanvas, Kinetic.Canvas);
|
||||
|
||||
|
@ -163,7 +163,7 @@
|
||||
drawFunc.call(this, bufferContext);
|
||||
bufferContext.restore();
|
||||
|
||||
if (hasShadow) {
|
||||
if (hasShadow && !canvas.hitCanvas) {
|
||||
context.save();
|
||||
context._applyShadow(this);
|
||||
context.drawImage(bufferCanvas._canvas, 0, 0);
|
||||
@ -184,7 +184,7 @@
|
||||
context.transform(o[0], o[1], o[2], o[3], o[4], o[5]);
|
||||
}
|
||||
|
||||
if (hasShadow) {
|
||||
if (hasShadow && !canvas.hitCanvas) {
|
||||
context.save();
|
||||
context._applyShadow(this);
|
||||
drawFunc.call(this, context);
|
||||
|
@ -471,6 +471,29 @@ suite('Shape', function() {
|
||||
|
||||
});
|
||||
|
||||
// ======================================================
|
||||
test('shape intersect with shadow', function(){
|
||||
var stage = addStage();
|
||||
|
||||
var layer = new Kinetic.Layer();
|
||||
|
||||
var rect = new Kinetic.Rect({
|
||||
fill: '#ff0000',
|
||||
x: 50,
|
||||
y: 50,
|
||||
width: 200,
|
||||
height: 200,
|
||||
draggable: true,
|
||||
shadowColor: '#000' // if all shadow properties removed, works fine
|
||||
});
|
||||
layer.add(rect);
|
||||
stage.add(layer);
|
||||
|
||||
//error here
|
||||
assert.equal(rect.intersects({x:52,y:52}), true);
|
||||
assert.equal(rect.intersects({x:45,y:45}), false);
|
||||
});
|
||||
|
||||
// ======================================================
|
||||
test('overloaded getters and setters', function(){
|
||||
var stage = addStage();
|
||||
|
Loading…
Reference in New Issue
Block a user