mirror of
https://github.com/konvajs/konva.git
synced 2025-11-18 09:07:30 +08:00
adjusted anonymous function wrapper for Node and Shape so that jsdocs wouldn't get tripped up
This commit is contained in:
32
src/Node.js
32
src/Node.js
@@ -1,4 +1,4 @@
|
|||||||
Kinetic.Node = (function() {
|
(function() {
|
||||||
/**
|
/**
|
||||||
* Node constructor. Nodes are entities that can be transformed, layered,
|
* Node constructor. Nodes are entities that can be transformed, layered,
|
||||||
* and have bound events. The stage, layers, groups, and shapes all extend Node.
|
* and have bound events. The stage, layers, groups, and shapes all extend Node.
|
||||||
@@ -24,11 +24,11 @@ Kinetic.Node = (function() {
|
|||||||
* @param {Boolean} [config.draggable]
|
* @param {Boolean} [config.draggable]
|
||||||
* @param {Function} [config.dragBoundFunc]
|
* @param {Function} [config.dragBoundFunc]
|
||||||
*/
|
*/
|
||||||
var Node = function(config) {
|
Kinetic.Node = function(config) {
|
||||||
this._nodeInit(config);
|
this._nodeInit(config);
|
||||||
};
|
};
|
||||||
|
|
||||||
Node.prototype = {
|
Kinetic.Node.prototype = {
|
||||||
_nodeInit: function(config) {
|
_nodeInit: function(config) {
|
||||||
this.defaultNodeAttrs = {
|
this.defaultNodeAttrs = {
|
||||||
visible: true,
|
visible: true,
|
||||||
@@ -962,32 +962,32 @@ Kinetic.Node = (function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// add getter and setter methods
|
// add getter and setter methods
|
||||||
Node.addSetters = function(constructor, arr) {
|
Kinetic.Node.addSetters = function(constructor, arr) {
|
||||||
var len = arr.length;
|
var len = arr.length;
|
||||||
for(var n = 0; n < len; n++) {
|
for(var n = 0; n < len; n++) {
|
||||||
var attr = arr[n];
|
var attr = arr[n];
|
||||||
this._addSetter(constructor, attr);
|
this._addSetter(constructor, attr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Node.addGetters = function(constructor, arr) {
|
Kinetic.Node.addGetters = function(constructor, arr) {
|
||||||
var len = arr.length;
|
var len = arr.length;
|
||||||
for(var n = 0; n < len; n++) {
|
for(var n = 0; n < len; n++) {
|
||||||
var attr = arr[n];
|
var attr = arr[n];
|
||||||
this._addGetter(constructor, attr);
|
this._addGetter(constructor, attr);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Node.addGettersSetters = function(constructor, arr) {
|
Kinetic.Node.addGettersSetters = function(constructor, arr) {
|
||||||
this.addSetters(constructor, arr);
|
this.addSetters(constructor, arr);
|
||||||
this.addGetters(constructor, arr);
|
this.addGetters(constructor, arr);
|
||||||
};
|
};
|
||||||
Node._addSetter = function(constructor, attr) {
|
Kinetic.Node._addSetter = function(constructor, attr) {
|
||||||
var that = this;
|
var that = this;
|
||||||
var method = 'set' + attr.charAt(0).toUpperCase() + attr.slice(1);
|
var method = 'set' + attr.charAt(0).toUpperCase() + attr.slice(1);
|
||||||
constructor.prototype[method] = function(val) {
|
constructor.prototype[method] = function(val) {
|
||||||
this.setAttr(attr, val);
|
this.setAttr(attr, val);
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
Node._addGetter = function(constructor, attr) {
|
Kinetic.Node._addGetter = function(constructor, attr) {
|
||||||
var that = this;
|
var that = this;
|
||||||
var method = 'get' + attr.charAt(0).toUpperCase() + attr.slice(1);
|
var method = 'get' + attr.charAt(0).toUpperCase() + attr.slice(1);
|
||||||
constructor.prototype[method] = function(arg) {
|
constructor.prototype[method] = function(arg) {
|
||||||
@@ -1007,10 +1007,10 @@ Kinetic.Node = (function() {
|
|||||||
* @param {DomElement} [container] optional container dom element used only if you're
|
* @param {DomElement} [container] optional container dom element used only if you're
|
||||||
* creating a stage node
|
* creating a stage node
|
||||||
*/
|
*/
|
||||||
Node.create = function(json, container) {
|
Kinetic.Node.create = function(json, container) {
|
||||||
return this._createNode(JSON.parse(json), container);
|
return this._createNode(JSON.parse(json), container);
|
||||||
};
|
};
|
||||||
Node._createNode = function(obj, container) {
|
Kinetic.Node._createNode = function(obj, container) {
|
||||||
var type;
|
var type;
|
||||||
|
|
||||||
// determine type
|
// determine type
|
||||||
@@ -1044,9 +1044,9 @@ Kinetic.Node = (function() {
|
|||||||
return no;
|
return no;
|
||||||
};
|
};
|
||||||
// add getters setters
|
// add getters setters
|
||||||
Node.addGettersSetters(Node, ['x', 'y', 'rotation', 'opacity', 'name', 'id']);
|
Kinetic.Node.addGettersSetters(Kinetic.Node, ['x', 'y', 'rotation', 'opacity', 'name', 'id']);
|
||||||
Node.addGetters(Node, ['scale', 'offset']);
|
Kinetic.Node.addGetters(Kinetic.Node, ['scale', 'offset']);
|
||||||
Node.addSetters(Node, ['width', 'height', 'listening', 'visible']);
|
Kinetic.Node.addSetters(Kinetic.Node, ['width', 'height', 'listening', 'visible']);
|
||||||
|
|
||||||
// aliases
|
// aliases
|
||||||
/**
|
/**
|
||||||
@@ -1054,13 +1054,13 @@ Kinetic.Node = (function() {
|
|||||||
* @name isListening
|
* @name isListening
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @methodOf Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
Node.prototype.isListening = Node.prototype.getListening;
|
Kinetic.Node.prototype.isListening = Kinetic.Node.prototype.getListening;
|
||||||
/**
|
/**
|
||||||
* Alias of getVisible()
|
* Alias of getVisible()
|
||||||
* @name isVisible
|
* @name isVisible
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @methodOf Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
Node.prototype.isVisible = Node.prototype.getVisible;
|
Kinetic.Node.prototype.isVisible = Kinetic.Node.prototype.getVisible;
|
||||||
|
|
||||||
// collection mappings
|
// collection mappings
|
||||||
var collectionMappings = ['on', 'off'];
|
var collectionMappings = ['on', 'off'];
|
||||||
@@ -1195,6 +1195,4 @@ Kinetic.Node = (function() {
|
|||||||
* @name getOffset
|
* @name getOffset
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @methodOf Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return Node;
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
14
src/Shape.js
14
src/Shape.js
@@ -1,4 +1,4 @@
|
|||||||
Kinetic.Shape = (function() {
|
(function() {
|
||||||
/**
|
/**
|
||||||
* Shape constructor. Shapes are primitive objects such as rectangles,
|
* Shape constructor. Shapes are primitive objects such as rectangles,
|
||||||
* circles, text, lines, etc.
|
* circles, text, lines, etc.
|
||||||
@@ -57,11 +57,11 @@ Kinetic.Shape = (function() {
|
|||||||
* @param {Number} [config.dragBounds.bottom]
|
* @param {Number} [config.dragBounds.bottom]
|
||||||
* @param {Number} [config.dragBounds.left]
|
* @param {Number} [config.dragBounds.left]
|
||||||
*/
|
*/
|
||||||
var Shape = function(config) {
|
Kinetic.Shape = function(config) {
|
||||||
this._initShape(config);
|
this._initShape(config);
|
||||||
};
|
};
|
||||||
|
|
||||||
Shape.prototype = {
|
Kinetic.Shape.prototype = {
|
||||||
_initShape: function(config) {
|
_initShape: function(config) {
|
||||||
this.nodeType = 'Shape';
|
this.nodeType = 'Shape';
|
||||||
|
|
||||||
@@ -365,11 +365,11 @@ Kinetic.Shape = (function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
Kinetic.Global.extend(Shape, Kinetic.Node);
|
Kinetic.Global.extend(Kinetic.Shape, Kinetic.Node);
|
||||||
|
|
||||||
// add getters and setters
|
// add getters and setters
|
||||||
Kinetic.Node.addGettersSetters(Shape, ['stroke', 'lineJoin', 'lineCap', 'strokeWidth', 'drawFunc', 'drawHitFunc', 'cornerRadius']);
|
Kinetic.Node.addGettersSetters(Kinetic.Shape, ['stroke', 'lineJoin', 'lineCap', 'strokeWidth', 'drawFunc', 'drawHitFunc', 'cornerRadius']);
|
||||||
Kinetic.Node.addGetters(Shape, ['shadow', 'fill']);
|
Kinetic.Node.addGetters(Kinetic.Shape, ['shadow', 'fill']);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set stroke color
|
* set stroke color
|
||||||
@@ -474,6 +474,4 @@ Kinetic.Shape = (function() {
|
|||||||
* @name getLineCap
|
* @name getLineCap
|
||||||
* @methodOf Kinetic.Shape.prototype
|
* @methodOf Kinetic.Shape.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
return Shape;
|
|
||||||
})();
|
})();
|
||||||
|
|||||||
Reference in New Issue
Block a user