mirror of
https://github.com/konvajs/konva.git
synced 2025-09-20 20:08:00 +08:00
fixes 400
This commit is contained in:
@@ -70,7 +70,7 @@
|
|||||||
* @memberof Kinetic.Shape.prototype
|
* @memberof Kinetic.Shape.prototype
|
||||||
*/
|
*/
|
||||||
hasShadow: function() {
|
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
|
* returns whether or not a fill is present
|
||||||
|
@@ -904,6 +904,33 @@ Test.Modules.EVENTS = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Test.Modules.DRAG_AND_DROP = {
|
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) {
|
'drag and drop elastic star with shadow': function(containerId) {
|
||||||
var stage = new Kinetic.Stage({
|
var stage = new Kinetic.Stage({
|
||||||
container: containerId,
|
container: containerId,
|
||||||
@@ -942,7 +969,7 @@ Test.Modules.DRAG_AND_DROP = {
|
|||||||
|
|
||||||
showHit(layer);
|
showHit(layer);
|
||||||
},
|
},
|
||||||
'*two draggable shapes': function(containerId) {
|
'two draggable shapes': function(containerId) {
|
||||||
var stage = new Kinetic.Stage({
|
var stage = new Kinetic.Stage({
|
||||||
container: containerId,
|
container: containerId,
|
||||||
width: 578,
|
width: 578,
|
||||||
|
@@ -120,6 +120,42 @@ Test.Modules.SHAPE = {
|
|||||||
}) === false, '(303, 153) should not intersect the 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) {
|
'custom shape with fill, stroke, and strokeWidth': function(containerId) {
|
||||||
var stage = new Kinetic.Stage({
|
var stage = new Kinetic.Stage({
|
||||||
container: containerId,
|
container: containerId,
|
||||||
|
Reference in New Issue
Block a user