Skip to content

Commit

Permalink
fixed #539 and also added size() overloader
Browse files Browse the repository at this point in the history
  • Loading branch information
ericdrowell committed Mar 21, 2014
1 parent a9b63fc commit e6b44bb
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 21 deletions.
40 changes: 25 additions & 15 deletions src/Node.js
Expand Up @@ -1295,26 +1295,11 @@
config.callback(img);
});
},
/**
* set size
* @method
* @memberof Kinetic.Node.prototype
* @param {Object} size
* @param {Number} size.width
* @param {Number} size.height
* @returns {Kinetic.Node}
*/
setSize: function(size) {
this.setWidth(size.width);
this.setHeight(size.height);
return this;
},
/**
* get size
* @method
* @memberof Kinetic.Node.prototype
* @returns {Object}
*/
getSize: function() {
return {
width: this.getWidth(),
Expand Down Expand Up @@ -2002,6 +1987,31 @@
* node.transformsEnabled('all');
*/



/**
* get/set node size
* @name size
* @method
* @memberof Kinetic.Node.prototype
* @param {Object} size
* @param {Number} size.width
* @param {Number} size.height
* @returns {Object}
* @example
* // get node size<br>
* var size = node.size();<br>
* var x = size.x;<br>
* var y = size.y;<br><br>
*
* // set size<br>
* node.size({<br>
* width: 100,<br>
* height: 200<br>
* });
*/
Kinetic.Factory.addOverloadedGetterSetter(Kinetic.Node, 'size');

Kinetic.Factory.backCompat(Kinetic.Node, {
rotateDeg: 'rotate',
setRotationDeg: 'setRotation',
Expand Down
5 changes: 1 addition & 4 deletions src/Tween.js
Expand Up @@ -48,7 +48,7 @@

this.anim = new Kinetic.Animation(function() {
that.tween.onEnterFrame();
}, node.getLayer() || node.getLayers());
}, node.getLayer());

this.tween = new Tween(key, function(i) {
that._tweenFunc(i);
Expand Down Expand Up @@ -199,7 +199,6 @@
reset: function() {
var node = this.node;
this.tween.reset();
(node.getLayer() || node.getLayers()).draw();
return this;
},
/**
Expand All @@ -212,7 +211,6 @@
seek: function(t) {
var node = this.node;
this.tween.seek(t * 1000);
(node.getLayer() || node.getLayers()).draw();
return this;
},
/**
Expand All @@ -234,7 +232,6 @@
finish: function() {
var node = this.node;
this.tween.finish();
(node.getLayer() || node.getLayers()).draw();
return this;
},
/**
Expand Down
2 changes: 1 addition & 1 deletion test/manual/manual-test.js
Expand Up @@ -98,7 +98,7 @@ suite('Manual', function() {
duration: 1,
x: 400,
y: 30,
rotation: Math.PI * 2,
rotation: 90,
opacity: 1,
strokeWidth: 6,
scaleX: 1.5
Expand Down
5 changes: 5 additions & 0 deletions test/unit/Node-test.js
Expand Up @@ -2759,6 +2759,11 @@ suite('Node', function() {
circle.position({x: 6, y: 8});
assert.equal(circle.position().x, 6);
assert.equal(circle.position().y, 8);

// because the height was set to 11, the width
// is also 11 because the node is a circle
assert.equal(circle.size().width, 11);
assert.equal(circle.size().height, 11);
});

test('cache shape', function(){
Expand Down
2 changes: 1 addition & 1 deletion test/unit/Tween-test.js
Expand Up @@ -63,7 +63,7 @@ suite('Tween', function() {
});

// ======================================================
test('tween node 2', function() {
test('destroy tween while tweening', function() {
var stage = addStage();

var layer = new Kinetic.Layer();
Expand Down

0 comments on commit e6b44bb

Please sign in to comment.