mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
removed .onContent() and replaced with .getDOM()
This commit is contained in:
39
src/Stage.js
39
src/Stage.js
@@ -1,4 +1,4 @@
|
||||
;///////////////////////////////////////////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// Stage
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
/**
|
||||
@@ -274,18 +274,6 @@ Kinetic.Stage.prototype = {
|
||||
}
|
||||
this._remove(layer);
|
||||
},
|
||||
/**
|
||||
* bind event listener to container DOM element
|
||||
* @param {String} typesStr
|
||||
* @param {function} handler
|
||||
*/
|
||||
onContent: function(typesStr, handler) {
|
||||
var types = typesStr.split(' ');
|
||||
for(var n = 0; n < types.length; n++) {
|
||||
var baseEvent = types[n];
|
||||
this.content.addEventListener(baseEvent, handler, false);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* add layer to stage
|
||||
* @param {Layer} layer
|
||||
@@ -355,7 +343,7 @@ Kinetic.Stage.prototype = {
|
||||
* @param {Object} point
|
||||
*/
|
||||
getIntersections: function() {
|
||||
var pos = Kinetic.GlobalObject._getPoint(arguments);
|
||||
var pos = Kinetic.GlobalObject._getPoint(arguments);
|
||||
var arr = [];
|
||||
var shapes = this.get('Shape');
|
||||
|
||||
@@ -368,6 +356,13 @@ Kinetic.Stage.prototype = {
|
||||
|
||||
return arr;
|
||||
},
|
||||
/**
|
||||
* get stage DOM node, which is a div element
|
||||
* with the class name "kineticjs-content"
|
||||
*/
|
||||
getDOM: function() {
|
||||
return this.content;
|
||||
},
|
||||
/**
|
||||
* detect event
|
||||
* @param {Shape} shape
|
||||
@@ -722,7 +717,7 @@ Kinetic.Stage.prototype = {
|
||||
_prepareDrag: function() {
|
||||
var that = this;
|
||||
|
||||
this.onContent('mousemove touchmove', function(evt) {
|
||||
this._onContent('mousemove touchmove', function(evt) {
|
||||
var go = Kinetic.GlobalObject;
|
||||
var node = go.drag.node;
|
||||
if(node) {
|
||||
@@ -784,7 +779,7 @@ Kinetic.Stage.prototype = {
|
||||
}
|
||||
}, false);
|
||||
|
||||
this.onContent('mouseup touchend mouseout', function(evt) {
|
||||
this._onContent('mouseup touchend mouseout', function(evt) {
|
||||
that._endDrag(evt);
|
||||
});
|
||||
},
|
||||
@@ -862,6 +857,18 @@ Kinetic.Stage.prototype = {
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
/**
|
||||
* bind event listener to container DOM element
|
||||
* @param {String} typesStr
|
||||
* @param {function} handler
|
||||
*/
|
||||
_onContent: function(typesStr, handler) {
|
||||
var types = typesStr.split(' ');
|
||||
for(var n = 0; n < types.length; n++) {
|
||||
var baseEvent = types[n];
|
||||
this.content.addEventListener(baseEvent, handler, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
// Extend Container and Node
|
||||
|
Reference in New Issue
Block a user