mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
getIntersections no longer returns visible shapes in the result set, and can also be called from any container
This commit is contained in:
@@ -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
|
||||
*/
|
||||
|
18
src/Stage.js
18
src/Stage.js
@@ -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"
|
||||
|
Reference in New Issue
Block a user