mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 18:27:58 +08:00
mark some methods as deprecated
This commit is contained in:
@@ -2,7 +2,7 @@ suite('MouseEvents', function() {
|
||||
|
||||
// NOTE: disable throttling so these tests can run synchronously
|
||||
Konva.enableThrottling = false;
|
||||
|
||||
|
||||
// ======================================================
|
||||
test('stage content mouse events', function(done) {
|
||||
|
||||
@@ -977,7 +977,7 @@ suite('MouseEvents', function() {
|
||||
y:0,
|
||||
width: 70,
|
||||
height: 70,
|
||||
rotationDeg: 45,
|
||||
rotation: 45,
|
||||
fill: 'green',
|
||||
id : 'greenRect'
|
||||
});
|
||||
@@ -1032,7 +1032,7 @@ suite('MouseEvents', function() {
|
||||
group2.on('mouseout', function() {
|
||||
group2Mouseout +=1;
|
||||
});
|
||||
|
||||
|
||||
var top = stage.content.getBoundingClientRect().top;
|
||||
|
||||
stage._mousemove({
|
||||
@@ -1172,7 +1172,7 @@ suite('MouseEvents', function() {
|
||||
Konva.DD._endDragAfter({dragEndNode:circle});
|
||||
|
||||
assert.equal(e.toString(), 'circle,group1,group2,layer,stage', 'problem with event bubbling');
|
||||
|
||||
|
||||
});
|
||||
|
||||
// ======================================================
|
||||
@@ -1347,4 +1347,4 @@ suite('MouseEvents', function() {
|
||||
});
|
||||
assert.equal(shape, circle);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1575,5 +1575,4 @@ suite('Container', function() {
|
||||
layer.add(circle1, circle2, circle3);
|
||||
assert.equal(layer.getChildren().length, 3, 'layer has exactly three children');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
@@ -246,7 +246,7 @@ suite('Node', function() {
|
||||
stage.add(layer);
|
||||
|
||||
// listening cache
|
||||
|
||||
|
||||
// prime the cache
|
||||
circle.isListening();
|
||||
|
||||
@@ -887,7 +887,7 @@ suite('Node', function() {
|
||||
156, 109, 70, 98,
|
||||
229, 109, 60, 98,
|
||||
287, 109, 41, 98
|
||||
]
|
||||
]
|
||||
},
|
||||
frameRate: 10,
|
||||
draggable: true,
|
||||
@@ -1459,16 +1459,11 @@ suite('Node', function() {
|
||||
stroke: 'black',
|
||||
strokeWidth: 4,
|
||||
draggable: true
|
||||
//rotationDeg: 60
|
||||
//rotationDeg: Math.PI / 3
|
||||
});
|
||||
|
||||
layer.add(rect);
|
||||
stage.add(layer);
|
||||
|
||||
//stage.rotateDeg(20);
|
||||
|
||||
//console.log(rect.getAbsoluteTransform().getTranslation())
|
||||
|
||||
stage.rotate(180 / 3);
|
||||
stage.setScale({x:0.5, y:0.5});
|
||||
@@ -1599,7 +1594,7 @@ suite('Node', function() {
|
||||
var circle = new Konva.Rect({
|
||||
x: 100,
|
||||
y: 100,
|
||||
rotationDeg: 20,
|
||||
rotation: 20,
|
||||
width: 100,
|
||||
height: 50,
|
||||
fill: 'green',
|
||||
@@ -1626,7 +1621,7 @@ suite('Node', function() {
|
||||
var rect = new Konva.Rect({
|
||||
x: 100,
|
||||
y: 100,
|
||||
rotationDeg: 20,
|
||||
rotation: 20,
|
||||
width: 100,
|
||||
height: 50,
|
||||
fill: 'green',
|
||||
@@ -2187,7 +2182,7 @@ suite('Node', function() {
|
||||
context.fillStrokeShape(this);
|
||||
};
|
||||
var triangle = new Konva.Shape({
|
||||
drawFunc: drawTriangle,
|
||||
sceneFunc: drawTriangle,
|
||||
fill: "#00D2FF",
|
||||
stroke: "black",
|
||||
strokeWidth: 4,
|
||||
@@ -2607,7 +2602,7 @@ suite('Node', function() {
|
||||
stroke: 'black',
|
||||
strokeWidth: 4,
|
||||
draggable: true,
|
||||
rotationDeg: 60,
|
||||
rotation: 60,
|
||||
scale: {
|
||||
x: 2,
|
||||
y: 1
|
||||
@@ -2821,10 +2816,10 @@ suite('Node', function() {
|
||||
assert.equal(circle.opacity(), 0.5);
|
||||
|
||||
circle.name('foo');
|
||||
assert.equal(circle.name(), 'foo');
|
||||
assert.equal(circle.name(), 'foo');
|
||||
|
||||
circle.id('bar');
|
||||
assert.equal(circle.id(), 'bar');
|
||||
assert.equal(circle.id(), 'bar');
|
||||
|
||||
circle.rotation(2);
|
||||
assert.equal(circle.rotation(), 2);
|
||||
@@ -2860,19 +2855,19 @@ suite('Node', function() {
|
||||
assert.equal(circle.offsetY(), 8);
|
||||
|
||||
circle.width(23);
|
||||
assert.equal(circle.width(), 23);
|
||||
assert.equal(circle.width(), 23);
|
||||
|
||||
circle.height(11);
|
||||
assert.equal(circle.height(), 11);
|
||||
assert.equal(circle.height(), 11);
|
||||
|
||||
circle.listening(false);
|
||||
assert.equal(circle.listening(), false);
|
||||
|
||||
circle.visible(false);
|
||||
assert.equal(circle.visible(), false);
|
||||
assert.equal(circle.visible(), false);
|
||||
|
||||
circle.transformsEnabled(false);
|
||||
assert.equal(circle.transformsEnabled(), false);
|
||||
assert.equal(circle.transformsEnabled(), false);
|
||||
|
||||
circle.position({x: 6, y: 8});
|
||||
assert.equal(circle.position().x, 6);
|
||||
@@ -2925,7 +2920,7 @@ suite('Node', function() {
|
||||
// document.body.appendChild(circle._cache.canvas.hit._canvas);
|
||||
|
||||
showHit(layer);
|
||||
|
||||
|
||||
//assert.equal(layer.getContext().getTrace(), 'clearRect(0,0,578,200);save();transform(1,0,0,1,74,74);beginPath();arc(0,0,70,0,6.283,false);closePath();fillStyle=green;fill();lineWidth=4;strokeStyle=black;stroke();restore();clearRect(0,0,578,200);save();transform(1,0,0,1,0,0);drawImage([object HTMLCanvasElement],0,0);restore();');
|
||||
|
||||
//assert.equal(circle._cache.canvas.scene.getContext().getTrace(), 'save();translate(74,74);beginPath();arc(0,0,70,0,6.283,false);closePath();fillStyle=green;fill();lineWidth=4;strokeStyle=black;stroke();restore();');
|
||||
@@ -2953,7 +2948,7 @@ suite('Node', function() {
|
||||
draggable: true,
|
||||
});
|
||||
group.add(rect);
|
||||
|
||||
|
||||
|
||||
assert.equal(rect._cache.canvas, undefined);
|
||||
group.cache({
|
||||
@@ -2962,12 +2957,12 @@ suite('Node', function() {
|
||||
width: 148,
|
||||
height: 148
|
||||
});
|
||||
stage.add(layer);
|
||||
stage.add(layer);
|
||||
|
||||
assert(group._cache.canvas.scene);
|
||||
assert(group._cache.canvas.hit);
|
||||
|
||||
|
||||
|
||||
layer.add(group);
|
||||
layer.draw();
|
||||
var shape = stage.getIntersection({
|
||||
@@ -3009,4 +3004,4 @@ suite('Node', function() {
|
||||
};
|
||||
imageObj.src = 'assets/darth-vader.jpg';
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@@ -1,60 +1,4 @@
|
||||
suite('Shape', function() {
|
||||
|
||||
// ======================================================
|
||||
test('shape color components', function() {
|
||||
var stage = addStage();
|
||||
var layer = new Konva.Layer();
|
||||
var rect = new Konva.Rect({
|
||||
x: 200,
|
||||
y: 90,
|
||||
width: 100,
|
||||
height: 50,
|
||||
fillGreen: 128,
|
||||
strokeRed: 255,
|
||||
draggable: true
|
||||
});
|
||||
|
||||
layer.add(rect);
|
||||
stage.add(layer);
|
||||
|
||||
assert.equal(rect.getFillRed(), 0, 'rect fill r should be 0');
|
||||
assert.equal(rect.getFillGreen(), 128, 'rect fill g should be 128');
|
||||
assert.equal(rect.getFillBlue(), 0, 'rect fill b should be 0');
|
||||
|
||||
assert.equal(rect.getStrokeRed(), 255, 'rect stroke r should be 255');
|
||||
assert.equal(rect.getStrokeGreen(), 0, 'rect stroke g should be 0');
|
||||
assert.equal(rect.getStrokeBlue(), 0, 'rect stroke b should be 0');
|
||||
|
||||
rect.fillRed(130);
|
||||
assert.equal(rect.fillRed(), 130, 'rect fill r should be 130');
|
||||
|
||||
rect.fillGreen(140);
|
||||
assert.equal(rect.fillGreen(), 140, 'rect fill g should be 140');
|
||||
|
||||
rect.fillBlue(150);
|
||||
assert.equal(rect.fillBlue(), 150, 'rect fill b should be 150');
|
||||
|
||||
rect.fillRed(0);
|
||||
rect.fillGreen(128);
|
||||
rect.fillBlue(0);
|
||||
|
||||
// var tween = new Konva.Tween({
|
||||
// node: rect,
|
||||
// fillGreen: 0,
|
||||
// fillRed: 255,
|
||||
// duration: 2,
|
||||
// fillAlpha: 0
|
||||
// });
|
||||
|
||||
// tween.play();
|
||||
|
||||
|
||||
|
||||
layer.draw();
|
||||
|
||||
//console.log(layer.getContext().getTrace());
|
||||
});
|
||||
|
||||
// ======================================================
|
||||
test('test intersects()', function() {
|
||||
var stage = addStage();
|
||||
@@ -104,8 +48,7 @@ suite('Shape', function() {
|
||||
var stage = addStage();
|
||||
var layer = new Konva.Layer();
|
||||
var shape = new Konva.Shape({
|
||||
drawFunc: function(context) {
|
||||
|
||||
sceneFunc: function(context) {
|
||||
context.beginPath();
|
||||
context.moveTo(0, 0);
|
||||
context.lineTo(100, 0);
|
||||
@@ -142,7 +85,7 @@ suite('Shape', function() {
|
||||
var stage = addStage();
|
||||
var layer = new Konva.Layer();
|
||||
var shape = new Konva.Shape({
|
||||
drawFunc: function(context) {
|
||||
sceneFunc: function(context) {
|
||||
context.beginPath();
|
||||
context.moveTo(0, 0);
|
||||
context.lineTo(100, 0);
|
||||
@@ -760,14 +703,6 @@ suite('Shape', function() {
|
||||
rect.stroke('blue');
|
||||
assert.equal(rect.stroke(), 'blue');
|
||||
|
||||
rect.strokeRed(255);
|
||||
assert.equal(rect.strokeRed(), 255);
|
||||
|
||||
rect.strokeGreen(20);
|
||||
assert.equal(rect.strokeGreen(), 20);
|
||||
|
||||
rect.strokeBlue(30);
|
||||
assert.equal(rect.strokeBlue(), 30);
|
||||
|
||||
rect.lineJoin('bevel');
|
||||
assert.equal(rect.lineJoin(), 'bevel');
|
||||
@@ -787,7 +722,7 @@ suite('Shape', function() {
|
||||
rect.dash([1]);
|
||||
assert.equal(rect.dash()[0], 1);
|
||||
|
||||
// NOTE: skipping the rest because it would take hours to test all possible methods.
|
||||
// NOTE: skipping the rest because it would take hours to test all possible methods.
|
||||
// This should hopefully be enough to test Factor overloaded methods
|
||||
|
||||
|
||||
@@ -844,27 +779,12 @@ suite('Shape', function() {
|
||||
layer.hitCanvas._canvas.style.border='2px solid black';
|
||||
});
|
||||
|
||||
test('back compat', function() {
|
||||
assert.notEqual(Konva.Shape.prototype.dashArray, undefined);
|
||||
assert.notEqual(Konva.Shape.prototype.setDashArray, undefined);
|
||||
assert.notEqual(Konva.Shape.prototype.getDashArray, undefined);
|
||||
});
|
||||
|
||||
test('test defaults', function() {
|
||||
var shape = new Konva.Shape();
|
||||
|
||||
assert.equal(shape.strokeRed(), 0);
|
||||
assert.equal(shape.strokeGreen(), 0);
|
||||
assert.equal(shape.strokeBlue(), 0);
|
||||
assert.equal(shape.strokeWidth(), 2);
|
||||
assert.equal(shape.shadowRed(), 0);
|
||||
assert.equal(shape.shadowGreen(), 0);
|
||||
assert.equal(shape.shadowBlue(), 0);
|
||||
assert.equal(shape.shadowOffsetX(), 0);
|
||||
assert.equal(shape.shadowOffsetY(), 0);
|
||||
assert.equal(shape.fillRed(), 0);
|
||||
assert.equal(shape.fillGreen(), 0);
|
||||
assert.equal(shape.fillBlue(), 0);
|
||||
assert.equal(shape.fillPatternX(), 0);
|
||||
assert.equal(shape.fillPatternY(), 0);
|
||||
assert.equal(shape.fillRadialGradientStartRadius(), 0);
|
||||
@@ -890,7 +810,7 @@ suite('Shape', function() {
|
||||
assert.equal(shape.fillRadialGradientEndPointY(), 0);
|
||||
assert.equal(shape.fillPatternRotation(), 0);
|
||||
});
|
||||
|
||||
|
||||
// ======================================================
|
||||
test.skip('hit graph when shape cached before adding to Layer', function() {
|
||||
var stage = addStage();
|
||||
@@ -1202,4 +1122,4 @@ suite('Shape', function() {
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
});
|
||||
|
@@ -567,7 +567,7 @@ suite('Stage', function() {
|
||||
stage.add(layer);
|
||||
showHit(layer);
|
||||
var circle = new Konva.Circle({
|
||||
fill : 'green',
|
||||
fill: 'green',
|
||||
radius: 50
|
||||
});
|
||||
layer.add(circle);
|
||||
|
Reference in New Issue
Block a user