intersects with shadow. close #1027

This commit is contained in:
Лаврёнов Антон 2014-10-02 22:41:51 +08:00
parent 362bcf9efc
commit a4ea6a65a5
5 changed files with 31 additions and 6 deletions

View File

@ -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

File diff suppressed because one or more lines are too long

View File

@ -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);

View File

@ -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);

View File

@ -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();