mirror of
https://github.com/konvajs/konva.git
synced 2025-12-05 03:24:23 +08:00
added new stage.getIntersects() method which allows you to obtain all the shapes that intersect a given point. Also enhanced all methods that require an x or y by allowing either two arguments to be passed in or an object to be passed in. Example foo(100, 50) or foo({x:100, y:50});
This commit is contained in:
15
src/Stage.js
15
src/Stage.js
@@ -351,11 +351,22 @@ Kinetic.Stage.prototype = {
|
||||
return this.attrs.height;
|
||||
},
|
||||
/**
|
||||
* get shapes in point
|
||||
* get shapes that intersect a point
|
||||
* @param {Object} point
|
||||
*/
|
||||
getShapesInPoint: function(pos) {
|
||||
getIntersections: function() {
|
||||
var pos = Kinetic.GlobalObject._getPoint(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;
|
||||
},
|
||||
/**
|
||||
* detect event
|
||||
|
||||
Reference in New Issue
Block a user