added back compat Factor method and plugged in the methods that changed with the 5.0.0 release

This commit is contained in:
Eric Rowell
2014-01-10 22:58:55 -08:00
parent 79701fcca0
commit 99e7ad4bf0
7 changed files with 49 additions and 5 deletions

View File

@@ -124,6 +124,13 @@
return this[getter]();
}
}
},
backCompat: function(constructor, methods) {
var key;
for (key in methods) {
constructor.prototype[key] = constructor.prototype[methods[key]];
}
}
};
})();

View File

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

View File

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

View File

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

View File

@@ -95,4 +95,10 @@
* // draw wedge clockwise<br>
* wedge.clockwise(true);
*/
Kinetic.Factory.backCompat(Kinetic.Wedge, {
angleDeg: 'angle',
getAngleDeg: 'getAngle',
setAngleDeg: 'setAngle'
});
})();

View File

@@ -2884,7 +2884,7 @@ suite('Node', function() {
y: -74,
width: 148,
height: 148,
showBorder: true
drawBorder: true
}).offset({
x: 74,
y: 74

View File

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