mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 18:27:58 +08:00
added back compat Factor method and plugged in the methods that changed with the 5.0.0 release
This commit is contained in:
@@ -124,6 +124,13 @@
|
||||
return this[getter]();
|
||||
}
|
||||
}
|
||||
},
|
||||
backCompat: function(constructor, methods) {
|
||||
var key;
|
||||
|
||||
for (key in methods) {
|
||||
constructor.prototype[key] = constructor.prototype[methods[key]];
|
||||
}
|
||||
}
|
||||
};
|
||||
})();
|
14
src/Node.js
14
src/Node.js
@@ -132,14 +132,14 @@
|
||||
* height: 200<br>
|
||||
* });<br><br>
|
||||
*
|
||||
* // cache a node and show a red border around the bounding box<br>
|
||||
* // cache a node and draw a red border around the bounding box<br>
|
||||
* // for debugging purposes<br>
|
||||
* node.cache({<br>
|
||||
* x: -30,<br>
|
||||
* y: -30,<br>
|
||||
* width: 100,<br>
|
||||
* height: 200,<br>
|
||||
* showBorder: true<br>
|
||||
* drawBorder: true<br>
|
||||
* });
|
||||
*/
|
||||
cache: function(config) {
|
||||
@@ -148,7 +148,7 @@
|
||||
y = conf.y || 0,
|
||||
width = conf.width || this.width(),
|
||||
height = conf.height || this.height(),
|
||||
showBorder = conf.showBorder || false,
|
||||
drawBorder = conf.drawBorder || false,
|
||||
cachedSceneCanvas = new Kinetic.SceneCanvas({
|
||||
pixelRatio: 1,
|
||||
width: width,
|
||||
@@ -179,7 +179,7 @@
|
||||
|
||||
// this will draw a red border around the cached box for
|
||||
// debugging purposes
|
||||
if (showBorder) {
|
||||
if (drawBorder) {
|
||||
sceneContext = cachedSceneCanvas.getContext();
|
||||
sceneContext.save();
|
||||
sceneContext.beginPath();
|
||||
@@ -1928,6 +1928,12 @@
|
||||
* node.transformsEnabled('all');
|
||||
*/
|
||||
|
||||
Kinetic.Factory.backCompat(Kinetic.Node, {
|
||||
rotateDeg: 'rotate',
|
||||
setRotationDeg: 'setRotation',
|
||||
getRotationDeg: 'getRotation'
|
||||
});
|
||||
|
||||
Kinetic.Collection.mapMethods([
|
||||
'on',
|
||||
'off',
|
||||
|
13
src/Shape.js
13
src/Shape.js
@@ -1486,4 +1486,17 @@
|
||||
* @returns {Number}
|
||||
*/
|
||||
|
||||
Kinetic.Factory.backCompat(Kinetic.Shape, {
|
||||
dashArray: 'dash',
|
||||
getDashArray: 'getDash',
|
||||
setDashArray: 'getDash',
|
||||
|
||||
drawFunc: 'sceneFunc',
|
||||
getDrawFunc: 'getSceneFunc',
|
||||
setDrawFunc: 'setSceneFunc',
|
||||
|
||||
drawHitFunc: 'hitFunc',
|
||||
getDrawHitFunc: 'getHitFunc',
|
||||
setDrawHitFunc: 'setHitFunc'
|
||||
});
|
||||
})();
|
||||
|
@@ -250,4 +250,10 @@
|
||||
* // set frame rate to 2 frames per second<br>
|
||||
* sprite.frameRate(2);
|
||||
*/
|
||||
|
||||
Kinetic.Factory.backCompat(Kinetic.Sprite, {
|
||||
index: 'frameIndex',
|
||||
getIndex: 'getFrameIndex',
|
||||
setIndex: 'setFrameIndex'
|
||||
});
|
||||
})();
|
||||
|
@@ -95,4 +95,10 @@
|
||||
* // draw wedge clockwise<br>
|
||||
* wedge.clockwise(true);
|
||||
*/
|
||||
|
||||
Kinetic.Factory.backCompat(Kinetic.Wedge, {
|
||||
angleDeg: 'angle',
|
||||
getAngleDeg: 'getAngle',
|
||||
setAngleDeg: 'setAngle'
|
||||
});
|
||||
})();
|
||||
|
@@ -2884,7 +2884,7 @@ suite('Node', function() {
|
||||
y: -74,
|
||||
width: 148,
|
||||
height: 148,
|
||||
showBorder: true
|
||||
drawBorder: true
|
||||
}).offset({
|
||||
x: 74,
|
||||
y: 74
|
||||
|
@@ -569,4 +569,10 @@ suite('Shape', function() {
|
||||
layer.hitCanvas._canvas.style.border='2px solid black';
|
||||
});
|
||||
|
||||
test('back compat', function() {
|
||||
assert.notEqual(Kinetic.Shape.prototype.dashArray, undefined);
|
||||
assert.notEqual(Kinetic.Shape.prototype.setDashArray, undefined);
|
||||
assert.notEqual(Kinetic.Shape.prototype.getDashArray, undefined);
|
||||
});
|
||||
|
||||
});
|
Reference in New Issue
Block a user