mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 15:23:44 +08:00
updated docs in prep for jsdoc3 migration
This commit is contained in:
parent
8c9d2b5459
commit
b1025be75e
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,4 +1,5 @@
|
|||||||
jsdoc-toolkit
|
jsdoc-toolkit
|
||||||
|
jsdoc-master
|
||||||
dist
|
dist
|
||||||
tests/js/unitTests.js
|
tests/js/unitTests.js
|
||||||
analysis
|
analysis
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
/**
|
/**
|
||||||
* Animation constructor. A stage is used to contain multiple layers and handle
|
* Animation constructor. A stage is used to contain multiple layers and handle
|
||||||
* @constructor
|
* @constructor
|
||||||
|
* @memberof Kinetic
|
||||||
* @param {Function} func function executed on each animation frame
|
* @param {Function} func function executed on each animation frame
|
||||||
* @param {Kinetic.Layer|Array} [layers] layer(s) to be redrawn. Can be a layer, an array of layers, or null. Not specifying a node will result in no redraw.
|
* @param {Kinetic.Layer|Array} [layers] layer(s) to be redrawn. Can be a layer, an array of layers, or null. Not specifying a node will result in no redraw.
|
||||||
*/
|
*/
|
||||||
@ -21,8 +22,8 @@
|
|||||||
Kinetic.Animation.prototype = {
|
Kinetic.Animation.prototype = {
|
||||||
/**
|
/**
|
||||||
* set layers to be redrawn on each animation frame
|
* set layers to be redrawn on each animation frame
|
||||||
* @name setLayers
|
* @method
|
||||||
* @methodOf Kinetic.Animation.prototype
|
* @memberof Kinetic.Animation.prototype
|
||||||
* @param {Kinetic.Layer|Array} [layers] layer(s) to be redrawn. Can be a layer, an array of layers, or null. Not specifying a node will result in no redraw.
|
* @param {Kinetic.Layer|Array} [layers] layer(s) to be redrawn. Can be a layer, an array of layers, or null. Not specifying a node will result in no redraw.
|
||||||
*/
|
*/
|
||||||
setLayers: function(layers) {
|
setLayers: function(layers) {
|
||||||
@ -44,16 +45,16 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get layers
|
* get layers
|
||||||
* @name getLayers
|
* @method
|
||||||
* @methodOf Kinetic.Animation.prototype
|
* @memberof Kinetic.Animation.prototype
|
||||||
*/
|
*/
|
||||||
getLayers: function() {
|
getLayers: function() {
|
||||||
return this.layers;
|
return this.layers;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* add layer. Returns true if the layer was added, and false if it was not
|
* add layer. Returns true if the layer was added, and false if it was not
|
||||||
* @name addLayer
|
* @method
|
||||||
* @methodOf Kinetic.Animation.prototype
|
* @memberof Kinetic.Animation.prototype
|
||||||
* @param {Kinetic.Layer} layer
|
* @param {Kinetic.Layer} layer
|
||||||
*/
|
*/
|
||||||
addLayer: function(layer) {
|
addLayer: function(layer) {
|
||||||
@ -79,8 +80,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* determine if animation is running or not. returns true or false
|
* determine if animation is running or not. returns true or false
|
||||||
* @name isRunning
|
* @method
|
||||||
* @methodOf Kinetic.Animation.prototype
|
* @memberof Kinetic.Animation.prototype
|
||||||
*/
|
*/
|
||||||
isRunning: function() {
|
isRunning: function() {
|
||||||
var a = Kinetic.Animation, animations = a.animations;
|
var a = Kinetic.Animation, animations = a.animations;
|
||||||
@ -93,8 +94,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* start animation
|
* start animation
|
||||||
* @name start
|
* @method
|
||||||
* @methodOf Kinetic.Animation.prototype
|
* @memberof Kinetic.Animation.prototype
|
||||||
*/
|
*/
|
||||||
start: function() {
|
start: function() {
|
||||||
this.stop();
|
this.stop();
|
||||||
@ -104,8 +105,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* stop animation
|
* stop animation
|
||||||
* @name stop
|
* @method
|
||||||
* @methodOf Kinetic.Animation.prototype
|
* @memberof Kinetic.Animation.prototype
|
||||||
*/
|
*/
|
||||||
stop: function() {
|
stop: function() {
|
||||||
Kinetic.Animation._removeAnimation(this);
|
Kinetic.Animation._removeAnimation(this);
|
||||||
@ -226,8 +227,8 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* get batch draw
|
* get batch draw
|
||||||
* @name batchDraw
|
* @method
|
||||||
* @methodOf Kinetic.Layer.prototype
|
* @memberof Kinetic.Layer.prototype
|
||||||
*/
|
*/
|
||||||
Kinetic.Layer.prototype.batchDraw = function() {
|
Kinetic.Layer.prototype.batchDraw = function() {
|
||||||
var batchAnim = Kinetic.Layer.batchAnim;
|
var batchAnim = Kinetic.Layer.batchAnim;
|
||||||
|
@ -1,12 +1,4 @@
|
|||||||
(function() {
|
(function() {
|
||||||
/**
|
|
||||||
* Container constructor. Containers are used to contain nodes or other containers
|
|
||||||
* @constructor
|
|
||||||
* @augments Kinetic.Node
|
|
||||||
* @param {Object} config
|
|
||||||
* {{NodeParams}}
|
|
||||||
* {{ContainerParams}}
|
|
||||||
*/
|
|
||||||
Kinetic.Util.addMethods(Kinetic.Container, {
|
Kinetic.Util.addMethods(Kinetic.Container, {
|
||||||
_containerInit: function(config) {
|
_containerInit: function(config) {
|
||||||
this.children = [];
|
this.children = [];
|
||||||
@ -14,16 +6,16 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get children
|
* get children
|
||||||
* @name getChildren
|
* @method
|
||||||
* @methodOf Kinetic.Container.prototype
|
* @memberof Kinetic.Container.prototype
|
||||||
*/
|
*/
|
||||||
getChildren: function() {
|
getChildren: function() {
|
||||||
return this.children;
|
return this.children;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* remove all children
|
* remove all children
|
||||||
* @name removeChildren
|
* @method
|
||||||
* @methodOf Kinetic.Container.prototype
|
* @memberof Kinetic.Container.prototype
|
||||||
*/
|
*/
|
||||||
removeChildren: function() {
|
removeChildren: function() {
|
||||||
while(this.children.length > 0) {
|
while(this.children.length > 0) {
|
||||||
@ -32,8 +24,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* add node to container
|
* add node to container
|
||||||
* @name add
|
* @method
|
||||||
* @methodOf Kinetic.Container.prototype
|
* @memberof Kinetic.Container.prototype
|
||||||
* @param {Node} child
|
* @param {Node} child
|
||||||
*/
|
*/
|
||||||
add: function(child) {
|
add: function(child) {
|
||||||
@ -51,8 +43,8 @@
|
|||||||
* ex:
|
* ex:
|
||||||
* var node = stage.get('#foo'); // selects node with id foo
|
* var node = stage.get('#foo'); // selects node with id foo
|
||||||
* var nodes = layer.get('.bar'); // selects nodes with name bar inside layer
|
* var nodes = layer.get('.bar'); // selects nodes with name bar inside layer
|
||||||
* @name get
|
* @method
|
||||||
* @methodOf Kinetic.Container.prototype
|
* @memberof Kinetic.Container.prototype
|
||||||
* @param {String} selector
|
* @param {String} selector
|
||||||
*/
|
*/
|
||||||
get: function(selector) {
|
get: function(selector) {
|
||||||
@ -131,8 +123,8 @@
|
|||||||
/**
|
/**
|
||||||
* determine if node is an ancestor
|
* determine if node is an ancestor
|
||||||
* of descendant
|
* of descendant
|
||||||
* @name isAncestorOf
|
* @method
|
||||||
* @methodOf Kinetic.Container.prototype
|
* @memberof Kinetic.Container.prototype
|
||||||
* @param {Kinetic.Node} node
|
* @param {Kinetic.Node} node
|
||||||
*/
|
*/
|
||||||
isAncestorOf: function(node) {
|
isAncestorOf: function(node) {
|
||||||
@ -148,8 +140,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* clone node
|
* clone node
|
||||||
* @name clone
|
* @method
|
||||||
* @methodOf Kinetic.Container.prototype
|
* @memberof Kinetic.Container.prototype
|
||||||
* @param {Object} attrs override attrs
|
* @param {Object} attrs override attrs
|
||||||
*/
|
*/
|
||||||
clone: function(obj) {
|
clone: function(obj) {
|
||||||
@ -164,8 +156,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get shapes that intersect a point
|
* get shapes that intersect a point
|
||||||
* @name getIntersections
|
* @method
|
||||||
* @methodOf Kinetic.Container.prototype
|
* @memberof Kinetic.Container.prototype
|
||||||
* @param {Object} point
|
* @param {Object} point
|
||||||
*/
|
*/
|
||||||
getIntersections: function() {
|
getIntersections: function() {
|
||||||
@ -183,9 +175,6 @@
|
|||||||
|
|
||||||
return arr;
|
return arr;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* set children indices
|
|
||||||
*/
|
|
||||||
_setChildrenIndices: function() {
|
_setChildrenIndices: function() {
|
||||||
var children = this.children, len = children.length;
|
var children = this.children, len = children.length;
|
||||||
for(var n = 0; n < len; n++) {
|
for(var n = 0; n < len; n++) {
|
||||||
@ -252,13 +241,15 @@
|
|||||||
/**
|
/**
|
||||||
* set clipping function
|
* set clipping function
|
||||||
* @name setClipFunc
|
* @name setClipFunc
|
||||||
* @methodOf Kinetic.Container.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Container.prototype
|
||||||
* @param {Number} deg
|
* @param {Number} deg
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get clipping function
|
* get clipping function
|
||||||
* @name getClipFunc
|
* @name getClipFunc
|
||||||
* @methodOf Kinetic.Container.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Container.prototype
|
||||||
*/
|
*/
|
||||||
})();
|
})();
|
||||||
|
@ -77,8 +77,8 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* initiate drag and drop
|
* initiate drag and drop
|
||||||
* @name startDrag
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
Kinetic.Node.prototype.startDrag = function() {
|
Kinetic.Node.prototype.startDrag = function() {
|
||||||
var dd = Kinetic.DD,
|
var dd = Kinetic.DD,
|
||||||
@ -104,8 +104,8 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* stop drag and drop
|
* stop drag and drop
|
||||||
* @name stopDrag
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
Kinetic.Node.prototype.stopDrag = function() {
|
Kinetic.Node.prototype.stopDrag = function() {
|
||||||
var dd = Kinetic.DD,
|
var dd = Kinetic.DD,
|
||||||
@ -116,8 +116,8 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* set draggable
|
* set draggable
|
||||||
* @name setDraggable
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {String} draggable
|
* @param {String} draggable
|
||||||
*/
|
*/
|
||||||
Kinetic.Node.prototype.setDraggable = function(draggable) {
|
Kinetic.Node.prototype.setDraggable = function(draggable) {
|
||||||
@ -141,8 +141,8 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* determine if node is currently in drag and drop mode
|
* determine if node is currently in drag and drop mode
|
||||||
* @name isDragging
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
Kinetic.Node.prototype.isDragging = function() {
|
Kinetic.Node.prototype.isDragging = function() {
|
||||||
var dd = Kinetic.DD;
|
var dd = Kinetic.DD;
|
||||||
@ -186,9 +186,6 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Node, 'dragBoundFunc');
|
Kinetic.Node.addGetterSetter(Kinetic.Node, 'dragBoundFunc');
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Node, 'dragOnTop', true);
|
|
||||||
|
|
||||||
Kinetic.Node.addGetter(Kinetic.Node, 'draggable', false);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set drag bound function. This is used to override the default
|
* set drag bound function. This is used to override the default
|
||||||
@ -198,26 +195,13 @@
|
|||||||
* @param {Function} dragBoundFunc
|
* @param {Function} dragBoundFunc
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
|
||||||
* set flag which enables or disables automatically moving the draggable node to a
|
|
||||||
* temporary top layer to improve performance. The default is true
|
|
||||||
* @name setDragOnTop
|
|
||||||
* @methodOf Kinetic.Node.prototype
|
|
||||||
* @param {Boolean} dragOnTop
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get dragBoundFunc
|
* get dragBoundFunc
|
||||||
* @name getDragBoundFunc
|
* @name getDragBoundFunc
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @methodOf Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
Kinetic.Node.addGetter(Kinetic.Node, 'draggable', false);
|
||||||
* get flag which enables or disables automatically moving the draggable node to a
|
|
||||||
* temporary top layer to improve performance.
|
|
||||||
* @name getDragOnTop
|
|
||||||
* @methodOf Kinetic.Node.prototype
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get draggable
|
* get draggable
|
||||||
@ -230,6 +214,13 @@
|
|||||||
* @name isDraggable
|
* @name isDraggable
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @methodOf Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* alias of getDraggable
|
||||||
|
* @name isDraggable
|
||||||
|
* @methodOf Kinetic.Node.prototype
|
||||||
|
*/
|
||||||
Kinetic.Node.prototype.isDraggable = Kinetic.Node.prototype.getDraggable;
|
Kinetic.Node.prototype.isDraggable = Kinetic.Node.prototype.getDraggable;
|
||||||
|
|
||||||
var html = document.getElementsByTagName('html')[0];
|
var html = document.getElementsByTagName('html')[0];
|
||||||
|
@ -26,14 +26,14 @@
|
|||||||
* THE SOFTWARE.
|
* THE SOFTWARE.
|
||||||
*/
|
*/
|
||||||
/**
|
/**
|
||||||
* @namespace
|
* @namespace Kinetic
|
||||||
*/
|
*/
|
||||||
var Kinetic = {};
|
var Kinetic = {};
|
||||||
(function() {
|
(function() {
|
||||||
Kinetic.version = '{{version}}';
|
Kinetic.version = '{{version}}';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace
|
* @namespace Filters
|
||||||
*/
|
*/
|
||||||
Kinetic.Filters = {};
|
Kinetic.Filters = {};
|
||||||
|
|
||||||
@ -41,6 +41,8 @@ var Kinetic = {};
|
|||||||
* 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.
|
||||||
* @constructor
|
* @constructor
|
||||||
|
* @memberof Kinetic
|
||||||
|
* @abstract
|
||||||
* @param {Object} config
|
* @param {Object} config
|
||||||
* {{NodeParams}}
|
* {{NodeParams}}
|
||||||
*/
|
*/
|
||||||
@ -52,6 +54,7 @@ var Kinetic = {};
|
|||||||
* 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.
|
||||||
* @constructor
|
* @constructor
|
||||||
|
* @memberof Kinetic
|
||||||
* @augments Kinetic.Node
|
* @augments Kinetic.Node
|
||||||
* @param {Object} config
|
* @param {Object} config
|
||||||
* {{ShapeParams}}
|
* {{ShapeParams}}
|
||||||
@ -64,7 +67,9 @@ var Kinetic = {};
|
|||||||
/**
|
/**
|
||||||
* Container constructor. Containers are used to contain nodes or other containers
|
* Container constructor. Containers are used to contain nodes or other containers
|
||||||
* @constructor
|
* @constructor
|
||||||
|
* @memberof Kinetic
|
||||||
* @augments Kinetic.Node
|
* @augments Kinetic.Node
|
||||||
|
* @abstract
|
||||||
* @param {Object} config
|
* @param {Object} config
|
||||||
* {{NodeParams}}
|
* {{NodeParams}}
|
||||||
* {{ContainerParams}}
|
* {{ContainerParams}}
|
||||||
@ -76,6 +81,7 @@ var Kinetic = {};
|
|||||||
/**
|
/**
|
||||||
* Stage constructor. A stage is used to contain multiple layers
|
* Stage constructor. A stage is used to contain multiple layers
|
||||||
* @constructor
|
* @constructor
|
||||||
|
* @memberof Kinetic
|
||||||
* @augments Kinetic.Container
|
* @augments Kinetic.Container
|
||||||
* @param {Object} config
|
* @param {Object} config
|
||||||
* @param {String|DomElement} config.container Container id or DOM element
|
* @param {String|DomElement} config.container Container id or DOM element
|
||||||
@ -90,6 +96,7 @@ var Kinetic = {};
|
|||||||
* Layer constructor. Layers are tied to their own canvas element and are used
|
* Layer constructor. Layers are tied to their own canvas element and are used
|
||||||
* to contain groups or shapes
|
* to contain groups or shapes
|
||||||
* @constructor
|
* @constructor
|
||||||
|
* @memberof Kinetic
|
||||||
* @augments Kinetic.Container
|
* @augments Kinetic.Container
|
||||||
* @param {Object} config
|
* @param {Object} config
|
||||||
* @param {Boolean} [config.clearBeforeDraw] set this property to false if you don't want
|
* @param {Boolean} [config.clearBeforeDraw] set this property to false if you don't want
|
||||||
@ -104,6 +111,7 @@ var Kinetic = {};
|
|||||||
/**
|
/**
|
||||||
* Group constructor. Groups are used to contain shapes or other groups.
|
* Group constructor. Groups are used to contain shapes or other groups.
|
||||||
* @constructor
|
* @constructor
|
||||||
|
* @memberof Kinetic
|
||||||
* @augments Kinetic.Container
|
* @augments Kinetic.Container
|
||||||
* @param {Object} config
|
* @param {Object} config
|
||||||
* {{NodeParams}}
|
* {{NodeParams}}
|
||||||
@ -114,7 +122,8 @@ var Kinetic = {};
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @namespace
|
* @namespace Global
|
||||||
|
* @memberof Kinetic
|
||||||
*/
|
*/
|
||||||
Kinetic.Global = {
|
Kinetic.Global = {
|
||||||
stages: [],
|
stages: [],
|
||||||
@ -125,9 +134,9 @@ var Kinetic = {};
|
|||||||
shapes: {},
|
shapes: {},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @method isDragging returns whether or not drag and drop
|
* returns whether or not drag and drop is currently active
|
||||||
* is currently active
|
* @method
|
||||||
* @methodOf Kinetic.Global
|
* @memberof Kinetic.Global
|
||||||
*/
|
*/
|
||||||
isDragging: function() {
|
isDragging: function() {
|
||||||
var dd = Kinetic.DD;
|
var dd = Kinetic.DD;
|
||||||
@ -143,9 +152,10 @@ var Kinetic = {};
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* @method isDragReady returns whether or not a drag and drop operation is ready, but may
|
* returns whether or not a drag and drop operation is ready, but may
|
||||||
* not necessarily have started
|
* not necessarily have started
|
||||||
* @methodOf Kinetic.Global
|
* @method
|
||||||
|
* @memberof Kinetic.Global
|
||||||
*/
|
*/
|
||||||
isDragReady: function() {
|
isDragReady: function() {
|
||||||
var dd = Kinetic.DD;
|
var dd = Kinetic.DD;
|
||||||
|
29
src/Layer.js
29
src/Layer.js
@ -12,8 +12,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get intersection object that contains shape and pixel data
|
* get intersection object that contains shape and pixel data
|
||||||
* @name getIntersection
|
* @method
|
||||||
* @methodOf Kinetic.Layer.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getIntersection: function() {
|
getIntersection: function() {
|
||||||
var pos = Kinetic.Util._getXY(Array.prototype.slice.call(arguments)),
|
var pos = Kinetic.Util._getXY(Array.prototype.slice.call(arguments)),
|
||||||
@ -60,32 +60,32 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get layer canvas
|
* get layer canvas
|
||||||
* @name getCanvas
|
* @method
|
||||||
* @methodOf Kinetic.Layer.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getCanvas: function() {
|
getCanvas: function() {
|
||||||
return this.canvas;
|
return this.canvas;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get layer hit canvas
|
* get layer hit canvas
|
||||||
* @name getHitCanvas
|
* @method
|
||||||
* @methodOf Kinetic.Layer.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getHitCanvas: function() {
|
getHitCanvas: function() {
|
||||||
return this.hitCanvas;
|
return this.hitCanvas;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get layer canvas context
|
* get layer canvas context
|
||||||
* @name getContext
|
* @method
|
||||||
* @methodOf Kinetic.Layer.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getContext: function() {
|
getContext: function() {
|
||||||
return this.getCanvas().getContext();
|
return this.getCanvas().getContext();
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* clear canvas tied to the layer
|
* clear canvas tied to the layer
|
||||||
* @name clear
|
* @method
|
||||||
* @methodOf Kinetic.Layer.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
clear: function() {
|
clear: function() {
|
||||||
this.getCanvas().clear();
|
this.getCanvas().clear();
|
||||||
@ -162,9 +162,6 @@
|
|||||||
getLayer: function() {
|
getLayer: function() {
|
||||||
return this;
|
return this;
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* remove layer from stage
|
|
||||||
*/
|
|
||||||
remove: function() {
|
remove: function() {
|
||||||
var stage = this.getStage(), canvas = this.getCanvas(), element = canvas.element;
|
var stage = this.getStage(), canvas = this.getCanvas(), element = canvas.element;
|
||||||
Kinetic.Node.prototype.remove.call(this);
|
Kinetic.Node.prototype.remove.call(this);
|
||||||
@ -183,7 +180,8 @@
|
|||||||
* set flag which determines if the layer is cleared or not
|
* set flag which determines if the layer is cleared or not
|
||||||
* before drawing
|
* before drawing
|
||||||
* @name setClearBeforeDraw
|
* @name setClearBeforeDraw
|
||||||
* @methodOf Kinetic.Layer.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Boolean} clearBeforeDraw
|
* @param {Boolean} clearBeforeDraw
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -191,6 +189,7 @@
|
|||||||
* get flag which determines if the layer is cleared or not
|
* get flag which determines if the layer is cleared or not
|
||||||
* before drawing
|
* before drawing
|
||||||
* @name getClearBeforeDraw
|
* @name getClearBeforeDraw
|
||||||
* @methodOf Kinetic.Layer.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
})();
|
})();
|
||||||
|
312
src/Node.js
312
src/Node.js
@ -46,10 +46,14 @@
|
|||||||
* of events delimmited by a space to bind multiple events at once
|
* of events delimmited by a space to bind multiple events at once
|
||||||
* such as 'mousedown mouseup mousemove'. Include a namespace to bind an
|
* such as 'mousedown mouseup mousemove'. Include a namespace to bind an
|
||||||
* event by name such as 'click.foobar'.
|
* event by name such as 'click.foobar'.
|
||||||
* @name on
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {String} typesStr e.g. 'click', 'mousedown touchstart', 'mousedown.foo touchstart.foo'
|
* @param {String} typesStr e.g. 'click', 'mousedown touchstart', 'mousedown.foo touchstart.foo'
|
||||||
* @param {Function} handler The handler function is passed an event object
|
* @param {Function} handler The handler function is passed an event object
|
||||||
|
* @example
|
||||||
|
* node.on('click', function() {<br>
|
||||||
|
* console.log('you clicked me!');<br>
|
||||||
|
* }
|
||||||
*/
|
*/
|
||||||
on: function(typesStr, handler) {
|
on: function(typesStr, handler) {
|
||||||
var types = typesStr.split(SPACE),
|
var types = typesStr.split(SPACE),
|
||||||
@ -86,8 +90,8 @@
|
|||||||
* include a namespace to remove an event binding by name
|
* include a namespace to remove an event binding by name
|
||||||
* such as 'click.foobar'. If you only give a name like '.foobar',
|
* such as 'click.foobar'. If you only give a name like '.foobar',
|
||||||
* all events in that namespace will be removed.
|
* all events in that namespace will be removed.
|
||||||
* @name off
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {String} typesStr e.g. 'click', 'mousedown touchstart', '.foobar'
|
* @param {String} typesStr e.g. 'click', 'mousedown touchstart', '.foobar'
|
||||||
*/
|
*/
|
||||||
off: function(typesStr) {
|
off: function(typesStr) {
|
||||||
@ -121,8 +125,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* remove child from container, but don't destroy it
|
* remove child from container, but don't destroy it
|
||||||
* @name remove
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
remove: function() {
|
remove: function() {
|
||||||
var parent = this.getParent();
|
var parent = this.getParent();
|
||||||
@ -135,8 +139,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* remove and destroy node
|
* remove and destroy node
|
||||||
* @name destroy
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
destroy: function() {
|
destroy: function() {
|
||||||
var parent = this.getParent(),
|
var parent = this.getParent(),
|
||||||
@ -159,8 +163,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get attr
|
* get attr
|
||||||
* @name getAttr
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {String} attr
|
* @param {String} attr
|
||||||
*/
|
*/
|
||||||
getAttr: function(attr) {
|
getAttr: function(attr) {
|
||||||
@ -175,8 +179,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* set attr
|
* set attr
|
||||||
* @name setAttr
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {String} attr
|
* @param {String} attr
|
||||||
* #param {*} val
|
* #param {*} val
|
||||||
*/
|
*/
|
||||||
@ -197,16 +201,12 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get attrs
|
* get attrs
|
||||||
* @name getAttrs
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getAttrs: function() {
|
getAttrs: function() {
|
||||||
return this.attrs || {};
|
return this.attrs || {};
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* @name createAttrs
|
|
||||||
* @methodOf Kinetic.Node.prototype
|
|
||||||
*/
|
|
||||||
createAttrs: function() {
|
createAttrs: function() {
|
||||||
if(this.attrs === undefined) {
|
if(this.attrs === undefined) {
|
||||||
this.attrs = {};
|
this.attrs = {};
|
||||||
@ -215,8 +215,8 @@
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* set attrs
|
* set attrs
|
||||||
* @name setAttrs
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Object} config object containing key value pairs
|
* @param {Object} config object containing key value pairs
|
||||||
*/
|
*/
|
||||||
setAttrs: function(config) {
|
setAttrs: function(config) {
|
||||||
@ -240,8 +240,8 @@
|
|||||||
* determine if node is visible or not. Node is visible only
|
* determine if node is visible or not. Node is visible only
|
||||||
* if it's visible and all of its ancestors are visible. If an ancestor
|
* if it's visible and all of its ancestors are visible. If an ancestor
|
||||||
* is invisible, this means that the node is also invisible
|
* is invisible, this means that the node is also invisible
|
||||||
* @name getVisible
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getVisible: function() {
|
getVisible: function() {
|
||||||
var visible = this.attrs.visible,
|
var visible = this.attrs.visible,
|
||||||
@ -261,8 +261,8 @@
|
|||||||
* determine if node is listening or not. Node is listening only
|
* determine if node is listening or not. Node is listening only
|
||||||
* if it's listening and all of its ancestors are listening. If an ancestor
|
* if it's listening and all of its ancestors are listening. If an ancestor
|
||||||
* is not listening, this means that the node is also not listening
|
* is not listening, this means that the node is also not listening
|
||||||
* @name getListening
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getListening: function() {
|
getListening: function() {
|
||||||
var listening = this.attrs.listening,
|
var listening = this.attrs.listening,
|
||||||
@ -280,24 +280,24 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* show node
|
* show node
|
||||||
* @name show
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
show: function() {
|
show: function() {
|
||||||
this.setVisible(true);
|
this.setVisible(true);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* hide node. Hidden nodes are no longer detectable
|
* hide node. Hidden nodes are no longer detectable
|
||||||
* @name hide
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
hide: function() {
|
hide: function() {
|
||||||
this.setVisible(false);
|
this.setVisible(false);
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get zIndex relative to the node's siblings who share the same parent
|
* get zIndex relative to the node's siblings who share the same parent
|
||||||
* @name getZIndex
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getZIndex: function() {
|
getZIndex: function() {
|
||||||
return this.index || 0;
|
return this.index || 0;
|
||||||
@ -305,8 +305,8 @@
|
|||||||
/**
|
/**
|
||||||
* get absolute z-index which takes into account sibling
|
* get absolute z-index which takes into account sibling
|
||||||
* and ancestor indices
|
* and ancestor indices
|
||||||
* @name getAbsoluteZIndex
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getAbsoluteZIndex: function() {
|
getAbsoluteZIndex: function() {
|
||||||
var level = this.getLevel(),
|
var level = this.getLevel(),
|
||||||
@ -345,8 +345,8 @@
|
|||||||
* get node level in node tree. Returns an integer.<br><br>
|
* get node level in node tree. Returns an integer.<br><br>
|
||||||
* e.g. Stage level will always be 0. Layers will always be 1. Groups and Shapes will always
|
* e.g. Stage level will always be 0. Layers will always be 1. Groups and Shapes will always
|
||||||
* be >= 2
|
* be >= 2
|
||||||
* @name getLevel
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getLevel: function() {
|
getLevel: function() {
|
||||||
var level = 0,
|
var level = 0,
|
||||||
@ -360,8 +360,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* set node position relative to parent
|
* set node position relative to parent
|
||||||
* @name setPosition
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
*/
|
*/
|
||||||
@ -372,8 +372,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get node position relative to parent
|
* get node position relative to parent
|
||||||
* @name getPosition
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getPosition: function() {
|
getPosition: function() {
|
||||||
return {
|
return {
|
||||||
@ -383,8 +383,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get absolute position relative to the top left corner of the stage container div
|
* get absolute position relative to the top left corner of the stage container div
|
||||||
* @name getAbsolutePosition
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getAbsolutePosition: function() {
|
getAbsolutePosition: function() {
|
||||||
var trans = this.getAbsoluteTransform(),
|
var trans = this.getAbsoluteTransform(),
|
||||||
@ -395,8 +395,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* set absolute position
|
* set absolute position
|
||||||
* @name setAbsolutePosition
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
*/
|
*/
|
||||||
@ -426,8 +426,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* move node by an amount relative to its current position
|
* move node by an amount relative to its current position
|
||||||
* @name move
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
*/
|
*/
|
||||||
@ -467,8 +467,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* rotate node by an amount in radians relative to its current rotation
|
* rotate node by an amount in radians relative to its current rotation
|
||||||
* @name rotate
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} theta
|
* @param {Number} theta
|
||||||
*/
|
*/
|
||||||
rotate: function(theta) {
|
rotate: function(theta) {
|
||||||
@ -476,8 +476,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* rotate node by an amount in degrees relative to its current rotation
|
* rotate node by an amount in degrees relative to its current rotation
|
||||||
* @name rotateDeg
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} deg
|
* @param {Number} deg
|
||||||
*/
|
*/
|
||||||
rotateDeg: function(deg) {
|
rotateDeg: function(deg) {
|
||||||
@ -485,8 +485,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* move node to the top of its siblings
|
* move node to the top of its siblings
|
||||||
* @name moveToTop
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
moveToTop: function() {
|
moveToTop: function() {
|
||||||
var index = this.index;
|
var index = this.index;
|
||||||
@ -497,8 +497,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* move node up
|
* move node up
|
||||||
* @name moveUp
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
moveUp: function() {
|
moveUp: function() {
|
||||||
var index = this.index,
|
var index = this.index,
|
||||||
@ -512,8 +512,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* move node down
|
* move node down
|
||||||
* @name moveDown
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
moveDown: function() {
|
moveDown: function() {
|
||||||
var index = this.index;
|
var index = this.index;
|
||||||
@ -526,8 +526,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* move node to the bottom of its siblings
|
* move node to the bottom of its siblings
|
||||||
* @name moveToBottom
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
moveToBottom: function() {
|
moveToBottom: function() {
|
||||||
var index = this.index;
|
var index = this.index;
|
||||||
@ -540,8 +540,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* set zIndex relative to siblings
|
* set zIndex relative to siblings
|
||||||
* @name setZIndex
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Integer} zIndex
|
* @param {Integer} zIndex
|
||||||
*/
|
*/
|
||||||
setZIndex: function(zIndex) {
|
setZIndex: function(zIndex) {
|
||||||
@ -552,8 +552,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get absolute opacity
|
* get absolute opacity
|
||||||
* @name getAbsoluteOpacity
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getAbsoluteOpacity: function() {
|
getAbsoluteOpacity: function() {
|
||||||
var absOpacity = this.getOpacity();
|
var absOpacity = this.getOpacity();
|
||||||
@ -564,8 +564,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* move node to another container
|
* move node to another container
|
||||||
* @name moveTo
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Container} newContainer
|
* @param {Container} newContainer
|
||||||
*/
|
*/
|
||||||
moveTo: function(newContainer) {
|
moveTo: function(newContainer) {
|
||||||
@ -574,8 +574,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* convert Node into an object for serialization. Returns an object.
|
* convert Node into an object for serialization. Returns an object.
|
||||||
* @name toObject
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
toObject: function() {
|
toObject: function() {
|
||||||
var type = Kinetic.Util,
|
var type = Kinetic.Util,
|
||||||
@ -600,32 +600,32 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* convert Node into a JSON string. Returns a JSON string.
|
* convert Node into a JSON string. Returns a JSON string.
|
||||||
* @name toJSON
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
toJSON: function() {
|
toJSON: function() {
|
||||||
return JSON.stringify(this.toObject());
|
return JSON.stringify(this.toObject());
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get parent container
|
* get parent container
|
||||||
* @name getParent
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getParent: function() {
|
getParent: function() {
|
||||||
return this.parent;
|
return this.parent;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get layer ancestor
|
* get layer ancestor
|
||||||
* @name getLayer
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getLayer: function() {
|
getLayer: function() {
|
||||||
return this.getParent().getLayer();
|
return this.getParent().getLayer();
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get stage ancestor
|
* get stage ancestor
|
||||||
* @name getStage
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getStage: function() {
|
getStage: function() {
|
||||||
if(this.getParent()) {
|
if(this.getParent()) {
|
||||||
@ -637,8 +637,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* fire event
|
* fire event
|
||||||
* @name fire
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {String} eventType event type. can be a regular event, like click, mouseover, or mouseout, or it can be a custom event, like myCustomEvent
|
* @param {String} eventType event type. can be a regular event, like click, mouseover, or mouseout, or it can be a custom event, like myCustomEvent
|
||||||
* @param {EventObject} evt event object
|
* @param {EventObject} evt event object
|
||||||
* @param {Boolean} bubble setting the value to false, or leaving it undefined, will result in the event
|
* @param {Boolean} bubble setting the value to false, or leaving it undefined, will result in the event
|
||||||
@ -657,8 +657,8 @@
|
|||||||
/**
|
/**
|
||||||
* get absolute transform of the node which takes into
|
* get absolute transform of the node which takes into
|
||||||
* account its ancestor transforms
|
* account its ancestor transforms
|
||||||
* @name getAbsoluteTransform
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getAbsoluteTransform: function() {
|
getAbsoluteTransform: function() {
|
||||||
// absolute transform
|
// absolute transform
|
||||||
@ -705,8 +705,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get transform of the node
|
* get transform of the node
|
||||||
* @name getTransform
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getTransform: function(useCache) {
|
getTransform: function(useCache) {
|
||||||
var cachedTransform = this.cachedTransform;
|
var cachedTransform = this.cachedTransform;
|
||||||
@ -719,8 +719,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* clone node. Returns a new Node instance with identical attributes
|
* clone node. Returns a new Node instance with identical attributes
|
||||||
* @name clone
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Object} attrs override attrs
|
* @param {Object} attrs override attrs
|
||||||
*/
|
*/
|
||||||
clone: function(obj) {
|
clone: function(obj) {
|
||||||
@ -757,8 +757,8 @@
|
|||||||
* Creates a composite data URL. If MIME type is not
|
* Creates a composite data URL. If MIME type is not
|
||||||
* specified, then "image/png" will result. For "image/jpeg", specify a quality
|
* specified, then "image/png" will result. For "image/jpeg", specify a quality
|
||||||
* level as quality (range 0.0 - 1.0)
|
* level as quality (range 0.0 - 1.0)
|
||||||
* @name toDataURL
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Object} config
|
* @param {Object} config
|
||||||
* @param {Function} config.callback function executed when the composite has completed
|
* @param {Function} config.callback function executed when the composite has completed
|
||||||
* @param {String} [config.mimeType] can be "image/png" or "image/jpeg".
|
* @param {String} [config.mimeType] can be "image/png" or "image/jpeg".
|
||||||
@ -800,8 +800,8 @@
|
|||||||
* converts node into an image. Since the toImage
|
* converts node into an image. Since the toImage
|
||||||
* method is asynchronous, a callback is required. toImage is most commonly used
|
* method is asynchronous, a callback is required. toImage is most commonly used
|
||||||
* to cache complex drawings as an image so that they don't have to constantly be redrawn
|
* to cache complex drawings as an image so that they don't have to constantly be redrawn
|
||||||
* @name toImage
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Object} config
|
* @param {Object} config
|
||||||
* @param {Function} config.callback function executed when the composite has completed
|
* @param {Function} config.callback function executed when the composite has completed
|
||||||
* @param {String} [config.mimeType] can be "image/png" or "image/jpeg".
|
* @param {String} [config.mimeType] can be "image/png" or "image/jpeg".
|
||||||
@ -821,8 +821,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* set size
|
* set size
|
||||||
* @name setSize
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} width
|
* @param {Number} width
|
||||||
* @param {Number} height
|
* @param {Number} height
|
||||||
*/
|
*/
|
||||||
@ -834,8 +834,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get size
|
* get size
|
||||||
* @name getSize
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getSize: function() {
|
getSize: function() {
|
||||||
return {
|
return {
|
||||||
@ -845,16 +845,16 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get width
|
* get width
|
||||||
* @name getWidth
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getWidth: function() {
|
getWidth: function() {
|
||||||
return this.attrs.width || 0;
|
return this.attrs.width || 0;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get height
|
* get height
|
||||||
* @name getHeight
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getHeight: function() {
|
getHeight: function() {
|
||||||
return this.attrs.height || 0;
|
return this.attrs.height || 0;
|
||||||
@ -926,8 +926,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* set id
|
* set id
|
||||||
* @name setId
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {String} id
|
* @param {String} id
|
||||||
*/
|
*/
|
||||||
setId: function(id) {
|
setId: function(id) {
|
||||||
@ -941,8 +941,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* set name
|
* set name
|
||||||
* @name setName
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {String} name
|
* @param {String} name
|
||||||
*/
|
*/
|
||||||
setName: function(name) {
|
setName: function(name) {
|
||||||
@ -956,8 +956,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get node type. Returns 'Stage', 'Layer', 'Group', or 'Shape'
|
* get node type. Returns 'Stage', 'Layer', 'Group', or 'Shape'
|
||||||
* @name getNodeType
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
getNodeType: function() {
|
getNodeType: function() {
|
||||||
return this.nodeType;
|
return this.nodeType;
|
||||||
@ -1013,8 +1013,8 @@
|
|||||||
},
|
},
|
||||||
/*
|
/*
|
||||||
* draw both scene and hit graphs. If the node being drawn is the stage, all of the layers will be cleared and redra
|
* draw both scene and hit graphs. If the node being drawn is the stage, all of the layers will be cleared and redra
|
||||||
* @name draw
|
* @method
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @memberof Kinetic.Node.prototype
|
||||||
* the scene renderer
|
* the scene renderer
|
||||||
*/
|
*/
|
||||||
draw: function() {
|
draw: function() {
|
||||||
@ -1208,8 +1208,8 @@
|
|||||||
* event handlers (it probably does), then you need to select the appropriate
|
* event handlers (it probably does), then you need to select the appropriate
|
||||||
* shapes after loading the stage and set these properties via on(), setDrawFunc(),
|
* shapes after loading the stage and set these properties via on(), setDrawFunc(),
|
||||||
* and setImage() methods
|
* and setImage() methods
|
||||||
* @name create
|
* @method
|
||||||
* @methodOf Kinetic.Node
|
* @memberof Kinetic.Node
|
||||||
* @param {String} JSON string
|
* @param {String} JSON string
|
||||||
* @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
|
||||||
@ -1256,14 +1256,16 @@
|
|||||||
/**
|
/**
|
||||||
* set x position
|
* set x position
|
||||||
* @name setX
|
* @name setX
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get x position
|
* get x position
|
||||||
* @name getX
|
* @name getX
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Node, 'y', 0, true);
|
Kinetic.Node.addGetterSetter(Kinetic.Node, 'y', 0, true);
|
||||||
@ -1271,14 +1273,16 @@
|
|||||||
/**
|
/**
|
||||||
* set y position
|
* set y position
|
||||||
* @name setY
|
* @name setY
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get y position
|
* get y position
|
||||||
* @name getY
|
* @name getY
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Kinetic.Node.addGetterSetter(Kinetic.Node, 'opacity', 1);
|
Kinetic.Node.addGetterSetter(Kinetic.Node, 'opacity', 1);
|
||||||
@ -1288,14 +1292,16 @@
|
|||||||
* A node with an opacity of 0 is fully transparent, and a node
|
* A node with an opacity of 0 is fully transparent, and a node
|
||||||
* with an opacity of 1 is fully opaque
|
* with an opacity of 1 is fully opaque
|
||||||
* @name setOpacity
|
* @name setOpacity
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Object} opacity
|
* @param {Object} opacity
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get opacity.
|
* get opacity.
|
||||||
* @name getOpacity
|
* @name getOpacity
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Kinetic.Node.addGetter(Kinetic.Node, 'name');
|
Kinetic.Node.addGetter(Kinetic.Node, 'name');
|
||||||
@ -1303,7 +1309,8 @@
|
|||||||
/**
|
/**
|
||||||
* get name
|
* get name
|
||||||
* @name getName
|
* @name getName
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Kinetic.Node.addGetter(Kinetic.Node, 'id');
|
Kinetic.Node.addGetter(Kinetic.Node, 'id');
|
||||||
@ -1311,7 +1318,8 @@
|
|||||||
/**
|
/**
|
||||||
* get id
|
* get id
|
||||||
* @name getId
|
* @name getId
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Kinetic.Node.addRotationGetterSetter(Kinetic.Node, 'rotation', 0, true);
|
Kinetic.Node.addRotationGetterSetter(Kinetic.Node, 'rotation', 0, true);
|
||||||
@ -1319,27 +1327,31 @@
|
|||||||
/**
|
/**
|
||||||
* set rotation in radians
|
* set rotation in radians
|
||||||
* @name setRotation
|
* @name setRotation
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} theta
|
* @param {Number} theta
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set rotation in degrees
|
* set rotation in degrees
|
||||||
* @name setRotationDeg
|
* @name setRotationDeg
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} deg
|
* @param {Number} deg
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get rotation in degrees
|
* get rotation in degrees
|
||||||
* @name getRotationDeg
|
* @name getRotationDeg
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get rotation in radians
|
* get rotation in radians
|
||||||
* @name getRotation
|
* @name getRotation
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Kinetic.Node.addPointGetterSetter(Kinetic.Node, 'scale', 1, true);
|
Kinetic.Node.addPointGetterSetter(Kinetic.Node, 'scale', 1, true);
|
||||||
@ -1349,39 +1361,45 @@
|
|||||||
* @name setScale
|
* @name setScale
|
||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set scale x
|
* set scale x
|
||||||
* @name setScaleX
|
* @name setScaleX
|
||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set scale y
|
* set scale y
|
||||||
* @name setScaleY
|
* @name setScaleY
|
||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get scale
|
* get scale
|
||||||
* @name getScale
|
* @name getScale
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get scale x
|
* get scale x
|
||||||
* @name getScaleX
|
* @name getScaleX
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get scale y
|
* get scale y
|
||||||
* @name getScaleY
|
* @name getScaleY
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Kinetic.Node.addPointGetterSetter(Kinetic.Node, 'skew', 0, true);
|
Kinetic.Node.addPointGetterSetter(Kinetic.Node, 'skew', 0, true);
|
||||||
@ -1391,39 +1409,45 @@
|
|||||||
* @name setSkew
|
* @name setSkew
|
||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set skew x
|
* set skew x
|
||||||
* @name setSkewX
|
* @name setSkewX
|
||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set skew y
|
* set skew y
|
||||||
* @name setSkewY
|
* @name setSkewY
|
||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get skew
|
* get skew
|
||||||
* @name getSkew
|
* @name getSkew
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get skew x
|
* get skew x
|
||||||
* @name getSkewX
|
* @name getSkewX
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get skew y
|
* get skew y
|
||||||
* @name getSkewY
|
* @name getSkewY
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Kinetic.Node.addPointGetterSetter(Kinetic.Node, 'offset', 0, true);
|
Kinetic.Node.addPointGetterSetter(Kinetic.Node, 'offset', 0, true);
|
||||||
@ -1431,7 +1455,8 @@
|
|||||||
/**
|
/**
|
||||||
* set offset. A node's offset defines the position and rotation point
|
* set offset. A node's offset defines the position and rotation point
|
||||||
* @name setOffset
|
* @name setOffset
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
*/
|
*/
|
||||||
@ -1439,33 +1464,38 @@
|
|||||||
/**
|
/**
|
||||||
* set offset x
|
* set offset x
|
||||||
* @name setOffsetX
|
* @name setOffsetX
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} x
|
* @param {Number} x
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set offset y
|
* set offset y
|
||||||
* @name setOffsetY
|
* @name setOffsetY
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} y
|
* @param {Number} y
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get offset
|
* get offset
|
||||||
* @name getOffset
|
* @name getOffset
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get offset x
|
* get offset x
|
||||||
* @name getOffsetX
|
* @name getOffsetX
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* get offset y
|
* get offset y
|
||||||
* @name getOffsetY
|
* @name getOffsetY
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Kinetic.Node.addSetter(Kinetic.Node, 'width');
|
Kinetic.Node.addSetter(Kinetic.Node, 'width');
|
||||||
@ -1473,7 +1503,8 @@
|
|||||||
/**
|
/**
|
||||||
* set width
|
* set width
|
||||||
* @name setWidth
|
* @name setWidth
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} width
|
* @param {Number} width
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -1482,7 +1513,8 @@
|
|||||||
/**
|
/**
|
||||||
* set height
|
* set height
|
||||||
* @name setHeight
|
* @name setHeight
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Number} height
|
* @param {Number} height
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -1491,7 +1523,8 @@
|
|||||||
/**
|
/**
|
||||||
* listen or don't listen to events
|
* listen or don't listen to events
|
||||||
* @name setListening
|
* @name setListening
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Boolean} listening
|
* @param {Boolean} listening
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -1500,7 +1533,8 @@
|
|||||||
/**
|
/**
|
||||||
* set visible
|
* set visible
|
||||||
* @name setVisible
|
* @name setVisible
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
* @param {Boolean} visible
|
* @param {Boolean} visible
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -1508,13 +1542,15 @@
|
|||||||
/**
|
/**
|
||||||
* Alias of getListening()
|
* Alias of getListening()
|
||||||
* @name isListening
|
* @name isListening
|
||||||
* @methodOf Kinetic.Node.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
Kinetic.Node.prototype.isListening = Kinetic.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
|
* @method
|
||||||
|
* @memberof Kinetic.Node.prototype
|
||||||
*/
|
*/
|
||||||
Kinetic.Node.prototype.isVisible = Kinetic.Node.prototype.getVisible;
|
Kinetic.Node.prototype.isVisible = Kinetic.Node.prototype.getVisible;
|
||||||
|
|
||||||
|
404
src/Shape.js
404
src/Shape.js
File diff suppressed because it is too large
Load Diff
84
src/Stage.js
84
src/Stage.js
@ -49,8 +49,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* set container dom element which contains the stage wrapper div element
|
* set container dom element which contains the stage wrapper div element
|
||||||
* @name setContainer
|
* @method
|
||||||
* @methodOf Kinetic.Stage.prototype
|
* @memberof Kinetic.Stage.prototype
|
||||||
* @param {DomElement} container can pass in a dom element or id string
|
* @param {DomElement} container can pass in a dom element or id string
|
||||||
*/
|
*/
|
||||||
setContainer: function(container) {
|
setContainer: function(container) {
|
||||||
@ -78,19 +78,21 @@
|
|||||||
/**
|
/**
|
||||||
* draw layer scene graphs
|
* draw layer scene graphs
|
||||||
* @name draw
|
* @name draw
|
||||||
* @methodOf Kinetic.Stage.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Stage.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* draw layer hit graphs
|
* draw layer hit graphs
|
||||||
* @name drawHit
|
* @name drawHit
|
||||||
* @methodOf Kinetic.Stage.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Stage.prototype
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* set height
|
* set height
|
||||||
* @name setHeight
|
* @method
|
||||||
* @methodOf Kinetic.Stage.prototype
|
* @memberof Kinetic.Stage.prototype
|
||||||
* @param {Number} height
|
* @param {Number} height
|
||||||
*/
|
*/
|
||||||
setHeight: function(height) {
|
setHeight: function(height) {
|
||||||
@ -99,8 +101,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* set width
|
* set width
|
||||||
* @name setWidth
|
* @method
|
||||||
* @methodOf Kinetic.Stage.prototype
|
* @memberof Kinetic.Stage.prototype
|
||||||
* @param {Number} width
|
* @param {Number} width
|
||||||
*/
|
*/
|
||||||
setWidth: function(width) {
|
setWidth: function(width) {
|
||||||
@ -109,8 +111,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* clear all layers
|
* clear all layers
|
||||||
* @name clear
|
* @method
|
||||||
* @methodOf Kinetic.Stage.prototype
|
* @memberof Kinetic.Stage.prototype
|
||||||
*/
|
*/
|
||||||
clear: function() {
|
clear: function() {
|
||||||
var layers = this.children,
|
var layers = this.children,
|
||||||
@ -123,6 +125,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* remove stage
|
* remove stage
|
||||||
|
* @method
|
||||||
|
* @memberof Kinetic.Stage.prototype
|
||||||
*/
|
*/
|
||||||
remove: function() {
|
remove: function() {
|
||||||
var content = this.content;
|
var content = this.content;
|
||||||
@ -134,24 +138,24 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get mouse position for desktop apps
|
* get mouse position for desktop apps
|
||||||
* @name getMousePosition
|
* @method
|
||||||
* @methodOf Kinetic.Stage.prototype
|
* @memberof Kinetic.Stage.prototype
|
||||||
*/
|
*/
|
||||||
getMousePosition: function() {
|
getMousePosition: function() {
|
||||||
return this.mousePos;
|
return this.mousePos;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get touch position for mobile apps
|
* get touch position for mobile apps
|
||||||
* @name getTouchPosition
|
* @method
|
||||||
* @methodOf Kinetic.Stage.prototype
|
* @memberof Kinetic.Stage.prototype
|
||||||
*/
|
*/
|
||||||
getTouchPosition: function() {
|
getTouchPosition: function() {
|
||||||
return this.touchPos;
|
return this.touchPos;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get pointer position which can be a touc position or mouse position
|
* get pointer position which can be a touc position or mouse position
|
||||||
* @name getPointerPosition
|
* @method
|
||||||
* @methodOf Kinetic.Stage.prototype
|
* @memberof Kinetic.Stage.prototype
|
||||||
*/
|
*/
|
||||||
getPointerPosition: function() {
|
getPointerPosition: function() {
|
||||||
return this.getTouchPosition() || this.getMousePosition();
|
return this.getTouchPosition() || this.getMousePosition();
|
||||||
@ -162,16 +166,16 @@
|
|||||||
/**
|
/**
|
||||||
* get stage content div element which has the
|
* get stage content div element which has the
|
||||||
* the class name "kineticjs-content"
|
* the class name "kineticjs-content"
|
||||||
* @name getContent
|
* @method
|
||||||
* @methodOf Kinetic.Stage.prototype
|
* @memberof Kinetic.Stage.prototype
|
||||||
*/
|
*/
|
||||||
getContent: function() {
|
getContent: function() {
|
||||||
return this.content;
|
return this.content;
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* Creates a composite data URL and requires a callback because the composite is generated asynchronously.
|
* Creates a composite data URL and requires a callback because the composite is generated asynchronously.
|
||||||
* @name toDataURL
|
* @method
|
||||||
* @methodOf Kinetic.Stage.prototype
|
* @memberof Kinetic.Stage.prototype
|
||||||
* @param {Object} config
|
* @param {Object} config
|
||||||
* @param {Function} config.callback function executed when the composite has completed
|
* @param {Function} config.callback function executed when the composite has completed
|
||||||
* @param {String} [config.mimeType] can be "image/png" or "image/jpeg".
|
* @param {String} [config.mimeType] can be "image/png" or "image/jpeg".
|
||||||
@ -223,8 +227,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* converts stage into an image.
|
* converts stage into an image.
|
||||||
* @name toImage
|
* @method
|
||||||
* @methodOf Kinetic.Stage.prototype
|
* @memberof Kinetic.Stage.prototype
|
||||||
* @param {Object} config
|
* @param {Object} config
|
||||||
* @param {Function} config.callback function executed when the composite has completed
|
* @param {Function} config.callback function executed when the composite has completed
|
||||||
* @param {String} [config.mimeType] can be "image/png" or "image/jpeg".
|
* @param {String} [config.mimeType] can be "image/png" or "image/jpeg".
|
||||||
@ -249,8 +253,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get intersection object that contains shape and pixel data
|
* get intersection object that contains shape and pixel data
|
||||||
* @name getIntersection
|
* @method
|
||||||
* @methodOf Kinetic.Stage.prototype
|
* @memberof Kinetic.Stage.prototype
|
||||||
* @param {Object} pos point object
|
* @param {Object} pos point object
|
||||||
*/
|
*/
|
||||||
getIntersection: function() {
|
getIntersection: function() {
|
||||||
@ -295,6 +299,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* add layer to stage
|
* add layer to stage
|
||||||
|
* @method
|
||||||
|
* @memberof Kinetic.Stage.prototype
|
||||||
* @param {Kinetic.Layer} layer
|
* @param {Kinetic.Layer} layer
|
||||||
*/
|
*/
|
||||||
add: function(layer) {
|
add: function(layer) {
|
||||||
@ -317,8 +323,8 @@
|
|||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* get layers
|
* get layers
|
||||||
* @name getLayers
|
* @method
|
||||||
* @methodOf Kinetic.Stage.prototype
|
* @memberof Kinetic.Stage.prototype
|
||||||
*/
|
*/
|
||||||
getLayers: function() {
|
getLayers: function() {
|
||||||
return this.getChildren();
|
return this.getChildren();
|
||||||
@ -330,10 +336,6 @@
|
|||||||
this._setMousePosition(evt);
|
this._setMousePosition(evt);
|
||||||
this._setTouchPosition(evt);
|
this._setTouchPosition(evt);
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* begin listening for events by adding event handlers
|
|
||||||
* to the container
|
|
||||||
*/
|
|
||||||
_bindContentEvents: function() {
|
_bindContentEvents: function() {
|
||||||
var that = this,
|
var that = this,
|
||||||
n;
|
n;
|
||||||
@ -513,10 +515,6 @@
|
|||||||
dd._drag(evt);
|
dd._drag(evt);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* set mouse positon for desktop apps
|
|
||||||
* @param {Event} evt
|
|
||||||
*/
|
|
||||||
_setMousePosition: function(evt) {
|
_setMousePosition: function(evt) {
|
||||||
var mouseX = evt.clientX - this._getContentPosition().left,
|
var mouseX = evt.clientX - this._getContentPosition().left,
|
||||||
mouseY = evt.clientY - this._getContentPosition().top;
|
mouseY = evt.clientY - this._getContentPosition().top;
|
||||||
@ -526,10 +524,6 @@
|
|||||||
y: mouseY
|
y: mouseY
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* set touch position for mobile apps
|
|
||||||
* @param {Event} evt
|
|
||||||
*/
|
|
||||||
_setTouchPosition: function(evt) {
|
_setTouchPosition: function(evt) {
|
||||||
var touch, touchX, touchY;
|
var touch, touchX, touchY;
|
||||||
|
|
||||||
@ -547,9 +541,6 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* get container position
|
|
||||||
*/
|
|
||||||
_getContentPosition: function() {
|
_getContentPosition: function() {
|
||||||
var rect = this.content.getBoundingClientRect();
|
var rect = this.content.getBoundingClientRect();
|
||||||
return {
|
return {
|
||||||
@ -557,9 +548,6 @@
|
|||||||
left: rect.left
|
left: rect.left
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* build dom
|
|
||||||
*/
|
|
||||||
_buildDOM: function() {
|
_buildDOM: function() {
|
||||||
// content
|
// content
|
||||||
this.content = document.createElement(DIV);
|
this.content = document.createElement(DIV);
|
||||||
@ -573,11 +561,6 @@
|
|||||||
|
|
||||||
this._resizeDOM();
|
this._resizeDOM();
|
||||||
},
|
},
|
||||||
/**
|
|
||||||
* bind event listener to container DOM element
|
|
||||||
* @param {String} typesStr
|
|
||||||
* @param {function} handler
|
|
||||||
*/
|
|
||||||
_onContent: function(typesStr, handler) {
|
_onContent: function(typesStr, handler) {
|
||||||
var types = typesStr.split(SPACE),
|
var types = typesStr.split(SPACE),
|
||||||
len = types.length,
|
len = types.length,
|
||||||
@ -597,6 +580,7 @@
|
|||||||
/**
|
/**
|
||||||
* get container DOM element
|
* get container DOM element
|
||||||
* @name getContainer
|
* @name getContainer
|
||||||
* @methodOf Kinetic.Stage.prototype
|
* @method
|
||||||
|
* @memberof Kinetic.Stage.prototype
|
||||||
*/
|
*/
|
||||||
})();
|
})();
|
||||||
|
Loading…
Reference in New Issue
Block a user