getIntersections no longer returns visible shapes in the result set, and can also be called from any container

This commit is contained in:
Eric Rowell
2012-07-06 21:45:18 -07:00
parent 1f3d1cc905
commit 9baaee2440
6 changed files with 98 additions and 72 deletions

View File

@@ -153,6 +153,24 @@ Kinetic.Container = Kinetic.Node.extend({
return false;
},
/**
* get shapes that intersect a point
* @param {Object} point
*/
getIntersections: function() {
var pos = Kinetic.Type._getXY(Array.prototype.slice.call(arguments));
var arr = [];
var shapes = this.get('Shape');
for(var n = 0; n < shapes.length; n++) {
var shape = shapes[n];
if(shape.isVisible() && shape.intersects(pos)) {
arr.push(shape);
}
}
return arr;
},
/**
* get all shapes inside container
*/

View File

@@ -281,24 +281,6 @@ Kinetic.Stage = Kinetic.Container.extend({
getStage: function() {
return this;
},
/**
* get shapes that intersect a point
* @param {Object} point
*/
getIntersections: function() {
var pos = Kinetic.Type._getXY(Array.prototype.slice.call(arguments));
var arr = [];
var shapes = this.get('Shape');
for(var n = 0; n < shapes.length; n++) {
var shape = shapes[n];
if(shape.intersects(pos)) {
arr.push(shape);
}
}
return arr;
},
/**
* get stage DOM node, which is a div element
* with the class name "kineticjs-content"