mirror of
https://github.com/konvajs/konva.git
synced 2025-09-20 03:18:00 +08:00
fixed #539 and also added size() overloader
This commit is contained in:
40
src/Node.js
40
src/Node.js
@@ -1295,26 +1295,11 @@
|
|||||||
config.callback(img);
|
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) {
|
setSize: function(size) {
|
||||||
this.setWidth(size.width);
|
this.setWidth(size.width);
|
||||||
this.setHeight(size.height);
|
this.setHeight(size.height);
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* get size
|
|
||||||
* @method
|
|
||||||
* @memberof Kinetic.Node.prototype
|
|
||||||
* @returns {Object}
|
|
||||||
*/
|
|
||||||
getSize: function() {
|
getSize: function() {
|
||||||
return {
|
return {
|
||||||
width: this.getWidth(),
|
width: this.getWidth(),
|
||||||
@@ -2002,6 +1987,31 @@
|
|||||||
* node.transformsEnabled('all');
|
* 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, {
|
Kinetic.Factory.backCompat(Kinetic.Node, {
|
||||||
rotateDeg: 'rotate',
|
rotateDeg: 'rotate',
|
||||||
setRotationDeg: 'setRotation',
|
setRotationDeg: 'setRotation',
|
||||||
|
@@ -48,7 +48,7 @@
|
|||||||
|
|
||||||
this.anim = new Kinetic.Animation(function() {
|
this.anim = new Kinetic.Animation(function() {
|
||||||
that.tween.onEnterFrame();
|
that.tween.onEnterFrame();
|
||||||
}, node.getLayer() || node.getLayers());
|
}, node.getLayer());
|
||||||
|
|
||||||
this.tween = new Tween(key, function(i) {
|
this.tween = new Tween(key, function(i) {
|
||||||
that._tweenFunc(i);
|
that._tweenFunc(i);
|
||||||
@@ -199,7 +199,6 @@
|
|||||||
reset: function() {
|
reset: function() {
|
||||||
var node = this.node;
|
var node = this.node;
|
||||||
this.tween.reset();
|
this.tween.reset();
|
||||||
(node.getLayer() || node.getLayers()).draw();
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -212,7 +211,6 @@
|
|||||||
seek: function(t) {
|
seek: function(t) {
|
||||||
var node = this.node;
|
var node = this.node;
|
||||||
this.tween.seek(t * 1000);
|
this.tween.seek(t * 1000);
|
||||||
(node.getLayer() || node.getLayers()).draw();
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
@@ -234,7 +232,6 @@
|
|||||||
finish: function() {
|
finish: function() {
|
||||||
var node = this.node;
|
var node = this.node;
|
||||||
this.tween.finish();
|
this.tween.finish();
|
||||||
(node.getLayer() || node.getLayers()).draw();
|
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
|
@@ -98,7 +98,7 @@ suite('Manual', function() {
|
|||||||
duration: 1,
|
duration: 1,
|
||||||
x: 400,
|
x: 400,
|
||||||
y: 30,
|
y: 30,
|
||||||
rotation: Math.PI * 2,
|
rotation: 90,
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
strokeWidth: 6,
|
strokeWidth: 6,
|
||||||
scaleX: 1.5
|
scaleX: 1.5
|
||||||
|
@@ -2759,6 +2759,11 @@ suite('Node', function() {
|
|||||||
circle.position({x: 6, y: 8});
|
circle.position({x: 6, y: 8});
|
||||||
assert.equal(circle.position().x, 6);
|
assert.equal(circle.position().x, 6);
|
||||||
assert.equal(circle.position().y, 8);
|
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(){
|
test('cache shape', function(){
|
||||||
|
@@ -63,7 +63,7 @@ suite('Tween', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// ======================================================
|
// ======================================================
|
||||||
test('tween node 2', function() {
|
test('destroy tween while tweening', function() {
|
||||||
var stage = addStage();
|
var stage = addStage();
|
||||||
|
|
||||||
var layer = new Kinetic.Layer();
|
var layer = new Kinetic.Layer();
|
||||||
|
Reference in New Issue
Block a user