fixed #539 and also added size() overloader

This commit is contained in:
Eric Rowell
2014-03-20 20:39:40 -07:00
parent a9b63fc8ed
commit e6b44bb75d
5 changed files with 33 additions and 21 deletions

View File

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

View File

@@ -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);
@@ -199,7 +199,6 @@
reset: function() {
var node = this.node;
this.tween.reset();
(node.getLayer() || node.getLayers()).draw();
return this;
},
/**
@@ -212,7 +211,6 @@
seek: function(t) {
var node = this.node;
this.tween.seek(t * 1000);
(node.getLayer() || node.getLayers()).draw();
return this;
},
/**
@@ -234,7 +232,6 @@
finish: function() {
var node = this.node;
this.tween.finish();
(node.getLayer() || node.getLayers()).draw();
return this;
},
/**

View File

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

View File

@@ -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(){

View File

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