fixes 400

This commit is contained in:
Eric Rowell
2013-07-23 10:47:06 -07:00
parent 3eea92d72e
commit 85c99c1bb9
3 changed files with 66 additions and 3 deletions

View File

@@ -70,7 +70,7 @@
* @memberof Kinetic.Shape.prototype
*/
hasShadow: function() {
return !!(this.getShadowColor() || this.getShadowBlur() || this.getShadowOffsetX() || this.getShadowOffsetY());
return (this.getShadowOpacity() !== 0 && !!(this.getShadowColor() || this.getShadowBlur() || this.getShadowOffsetX() || this.getShadowOffsetY()));
},
/**
* returns whether or not a fill is present

View File

@@ -904,6 +904,33 @@ Test.Modules.EVENTS = {
};
Test.Modules.DRAG_AND_DROP = {
'*drag and drop layer with offset': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,
height: 200
});
var layer = new Kinetic.Layer({
offset: [50, 50],
draggable: true
});
var star = new Kinetic.Star({
x: 200,
y: 100,
numPoints: 5,
innerRadius: 40,
outerRadius: 70,
fill: 'green',
stroke: 'blue',
strokeWidth: 5,
lineJoin: "round"
});
layer.add(star);
stage.add(layer);
layer.draw();
},
'drag and drop elastic star with shadow': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
@@ -942,7 +969,7 @@ Test.Modules.DRAG_AND_DROP = {
showHit(layer);
},
'*two draggable shapes': function(containerId) {
'two draggable shapes': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,

View File

@@ -120,6 +120,42 @@ Test.Modules.SHAPE = {
}) === false, '(303, 153) should not intersect the shape');
},
'test hasShadow() method': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,
height: 200
});
var layer = new Kinetic.Layer();
var shape = new Kinetic.Shape({
drawFunc: function(canvas) {
var context = canvas.getContext();
context.beginPath();
context.moveTo(0, 0);
context.lineTo(100, 0);
context.lineTo(100, 100);
context.closePath();
canvas.fillStroke(this);
},
x: 10,
y: 10,
fill: 'green',
stroke: 'blue',
strokeWidth: 5,
shadowColor: 'black',
shadowOffset: 10,
shadowOpacity: 0
});
layer.add(shape);
stage.add(layer);
test(!shape.hasShadow(), 'shape should not have a shadow because opacity is 0');
shape.setShadowOpacity(0.5);
test(shape.hasShadow(), 'shape should have a shadow because opacity is nonzero');
},
'custom shape with fill, stroke, and strokeWidth': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,