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](); 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> * height: 200<br>
* });<br><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> * // for debugging purposes<br>
* node.cache({<br> * node.cache({<br>
* x: -30,<br> * x: -30,<br>
* y: -30,<br> * y: -30,<br>
* width: 100,<br> * width: 100,<br>
* height: 200,<br> * height: 200,<br>
* showBorder: true<br> * drawBorder: true<br>
* }); * });
*/ */
cache: function(config) { cache: function(config) {
@@ -148,7 +148,7 @@
y = conf.y || 0, y = conf.y || 0,
width = conf.width || this.width(), width = conf.width || this.width(),
height = conf.height || this.height(), height = conf.height || this.height(),
showBorder = conf.showBorder || false, drawBorder = conf.drawBorder || false,
cachedSceneCanvas = new Kinetic.SceneCanvas({ cachedSceneCanvas = new Kinetic.SceneCanvas({
pixelRatio: 1, pixelRatio: 1,
width: width, width: width,
@@ -179,7 +179,7 @@
// this will draw a red border around the cached box for // this will draw a red border around the cached box for
// debugging purposes // debugging purposes
if (showBorder) { if (drawBorder) {
sceneContext = cachedSceneCanvas.getContext(); sceneContext = cachedSceneCanvas.getContext();
sceneContext.save(); sceneContext.save();
sceneContext.beginPath(); sceneContext.beginPath();
@@ -1928,6 +1928,12 @@
* node.transformsEnabled('all'); * node.transformsEnabled('all');
*/ */
Kinetic.Factory.backCompat(Kinetic.Node, {
rotateDeg: 'rotate',
setRotationDeg: 'setRotation',
getRotationDeg: 'getRotation'
});
Kinetic.Collection.mapMethods([ Kinetic.Collection.mapMethods([
'on', 'on',
'off', 'off',

View File

@@ -1486,4 +1486,17 @@
* @returns {Number} * @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> * // set frame rate to 2 frames per second<br>
* sprite.frameRate(2); * sprite.frameRate(2);
*/ */
Kinetic.Factory.backCompat(Kinetic.Sprite, {
index: 'frameIndex',
getIndex: 'getFrameIndex',
setIndex: 'setFrameIndex'
});
})(); })();

View File

@@ -95,4 +95,10 @@
* // draw wedge clockwise<br> * // draw wedge clockwise<br>
* wedge.clockwise(true); * 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, y: -74,
width: 148, width: 148,
height: 148, height: 148,
showBorder: true drawBorder: true
}).offset({ }).offset({
x: 74, x: 74,
y: 74 y: 74

View File

@@ -569,4 +569,10 @@ suite('Shape', function() {
layer.hitCanvas._canvas.style.border='2px solid black'; 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);
});
}); });