mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
removed createAttrs method and cleaned up init logic
This commit is contained in:
parent
37a15817b5
commit
1fc57bed4c
@ -2,7 +2,6 @@
|
||||
Kinetic.Util.addMethods(Kinetic.Group, {
|
||||
___init: function(config) {
|
||||
this.nodeType = 'Group';
|
||||
this.createAttrs();
|
||||
// call super constructor
|
||||
Kinetic.Container.call(this, config);
|
||||
}
|
||||
|
@ -5,7 +5,6 @@
|
||||
Kinetic.Util.addMethods(Kinetic.Layer, {
|
||||
___init: function(config) {
|
||||
this.nodeType = 'Layer';
|
||||
this.createAttrs();
|
||||
this.canvas = new Kinetic.SceneCanvas();
|
||||
this.hitCanvas = new Kinetic.HitCanvas();
|
||||
// call super constructor
|
||||
|
@ -37,6 +37,7 @@
|
||||
_init: function(config) {
|
||||
this._id = Kinetic.Global.idCounter++;
|
||||
this.eventListeners = {};
|
||||
this.attrs = {};
|
||||
this.setAttrs(config);
|
||||
},
|
||||
/**
|
||||
@ -238,13 +239,6 @@
|
||||
getAttrs: function() {
|
||||
return this.attrs || {};
|
||||
},
|
||||
createAttrs: function() {
|
||||
if(this.attrs === undefined) {
|
||||
this.attrs = {};
|
||||
}
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* set multiple attrs at once using an object literal
|
||||
* @method
|
||||
|
@ -37,7 +37,6 @@
|
||||
this.colorKey = key;
|
||||
shapes[key] = this;
|
||||
|
||||
this.createAttrs();
|
||||
// call super constructor
|
||||
Kinetic.Node.call(this, config);
|
||||
|
||||
|
@ -38,7 +38,6 @@
|
||||
|
||||
Kinetic.Util.addMethods(Kinetic.Stage, {
|
||||
___init: function(config) {
|
||||
this.createAttrs();
|
||||
// call super constructor
|
||||
Kinetic.Container.call(this, config);
|
||||
this.nodeType = STAGE;
|
||||
|
@ -58,7 +58,6 @@
|
||||
____init: function(config) {
|
||||
var that = this;
|
||||
|
||||
this.createAttrs();
|
||||
this.className = LABEL;
|
||||
Kinetic.Group.call(this, config);
|
||||
|
||||
@ -173,7 +172,6 @@
|
||||
|
||||
Kinetic.Tag.prototype = {
|
||||
___init: function(config) {
|
||||
this.createAttrs();
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = 'Tag';
|
||||
},
|
||||
|
@ -26,8 +26,6 @@
|
||||
|
||||
Kinetic.RegularPolygon.prototype = {
|
||||
___init: function(config) {
|
||||
this.createAttrs();
|
||||
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = 'RegularPolygon';
|
||||
|
@ -28,8 +28,6 @@
|
||||
|
||||
Kinetic.Star.prototype = {
|
||||
___init: function(config) {
|
||||
this.createAttrs();
|
||||
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = 'Star';
|
||||
|
@ -42,8 +42,6 @@
|
||||
Kinetic.TextPath.prototype = {
|
||||
___init: function(config) {
|
||||
var that = this;
|
||||
|
||||
this.createAttrs();
|
||||
this.dummyCanvas = document.createElement('canvas');
|
||||
this.dataArray = [];
|
||||
|
||||
|
@ -27,7 +27,6 @@
|
||||
Kinetic.Blob.prototype = {
|
||||
___init: function(config) {
|
||||
var that = this;
|
||||
this.createAttrs();
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = 'Blob';
|
||||
|
@ -37,7 +37,6 @@
|
||||
|
||||
Kinetic.Circle.prototype = {
|
||||
___init: function(config) {
|
||||
this.createAttrs();
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = CIRCLE;
|
||||
|
@ -18,8 +18,6 @@
|
||||
|
||||
Kinetic.Ellipse.prototype = {
|
||||
___init: function(config) {
|
||||
this.createAttrs();
|
||||
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = ELLIPSE;
|
||||
|
@ -37,8 +37,6 @@
|
||||
|
||||
Kinetic.Line.prototype = {
|
||||
___init: function(config) {
|
||||
this.createAttrs();
|
||||
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = 'Line';
|
||||
|
@ -23,8 +23,6 @@
|
||||
|
||||
Kinetic.Polygon.prototype = {
|
||||
___init: function(config) {
|
||||
this.createAttrs();
|
||||
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = 'Polygon';
|
||||
|
@ -23,7 +23,6 @@
|
||||
|
||||
Kinetic.Rect.prototype = {
|
||||
___init: function(config) {
|
||||
this.createAttrs();
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = 'Rect';
|
||||
},
|
||||
|
@ -27,7 +27,6 @@
|
||||
Kinetic.Spline.prototype = {
|
||||
___init: function(config) {
|
||||
var that = this;
|
||||
this.createAttrs();
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = 'Spline';
|
||||
|
@ -72,8 +72,6 @@
|
||||
|
||||
Kinetic.Sprite.prototype = {
|
||||
___init: function(config) {
|
||||
this.createAttrs();
|
||||
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = 'Sprite';
|
||||
|
@ -68,12 +68,13 @@
|
||||
Kinetic.Text.prototype = {
|
||||
___init: function(config) {
|
||||
var that = this;
|
||||
this.createAttrs();
|
||||
|
||||
// since width and height work a bit different for Text,
|
||||
// we need to default the values here
|
||||
this.attrs.width = AUTO;
|
||||
this.attrs.height = AUTO;
|
||||
if (config.width === undefined) {
|
||||
config.width = AUTO;
|
||||
}
|
||||
if (config.height === undefined) {
|
||||
config.height = AUTO;
|
||||
}
|
||||
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
|
@ -27,8 +27,6 @@
|
||||
|
||||
Kinetic.Wedge.prototype = {
|
||||
___init: function(config) {
|
||||
this.createAttrs();
|
||||
|
||||
// call super constructor
|
||||
Kinetic.Shape.call(this, config);
|
||||
this.className = 'Wedge';
|
||||
|
@ -54,7 +54,7 @@ Test.Modules.Text = {
|
||||
group.add(text);
|
||||
layer.add(group);
|
||||
stage.add(layer);
|
||||
|
||||
|
||||
test(text.getClassName() === 'Text', 'getClassName should be Text');
|
||||
},
|
||||
'text getters and setters': function(containerId) {
|
||||
@ -98,7 +98,6 @@ Test.Modules.Text = {
|
||||
|
||||
test(text.getX() === stage.getWidth() / 2, 'text box x should be in center of stage');
|
||||
test(text.getY() === stage.getHeight() / 2, 'text box y should be in center of stage');
|
||||
|
||||
test(text.getText() === 'Hello World!', 'text should be Hello World!');
|
||||
test(text.getFontSize() == 50, 'font size should 50');
|
||||
test(text.getFontFamily() == 'Calibri', 'font family should be Calibri');
|
||||
@ -112,7 +111,6 @@ Test.Modules.Text = {
|
||||
test(text.getPadding() === 10, 'padding should be 10');
|
||||
test(text.getShadowColor() === 'black', 'text box shadow color should be black');
|
||||
test(text.getDraggable() === true, 'text should be draggable');
|
||||
|
||||
test(text.getWidth() === 400, 'box width should be 400');
|
||||
test(text.getHeight() === 100, 'box height should be 100');
|
||||
test(text.getTextWidth() > 0, 'text width should be greater than 0');
|
||||
@ -164,7 +162,7 @@ Test.Modules.Text = {
|
||||
height: 200
|
||||
});
|
||||
var layer = new Kinetic.Layer();
|
||||
|
||||
|
||||
var rect = new Kinetic.Rect({
|
||||
x: 10,
|
||||
y: 10,
|
||||
@ -204,14 +202,14 @@ Test.Modules.Text = {
|
||||
width: 50,
|
||||
duration: 20
|
||||
});
|
||||
|
||||
|
||||
rect.transitionTo({
|
||||
width: 50,
|
||||
duration: 20
|
||||
});
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
},
|
||||
'text multi line with shadows': function(containerId) {
|
||||
var stage = new Kinetic.Stage({
|
||||
@ -271,15 +269,15 @@ Test.Modules.Text = {
|
||||
|
||||
var width = text.getWidth();
|
||||
var height = text.getHeight();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
layer.add(text);
|
||||
stage.add(layer);
|
||||
|
||||
text.setFontSize(30);
|
||||
layer.draw();
|
||||
|
||||
|
||||
//console.log(text.getHeight() + ',' + height);
|
||||
|
||||
test(text.getWidth() > width, 'text box width should have increased.');
|
||||
|
Loading…
Reference in New Issue
Block a user