diff --git a/dist/kinetic-core.js b/dist/kinetic-core.js index bfe0dc5b..55795380 100644 --- a/dist/kinetic-core.js +++ b/dist/kinetic-core.js @@ -1218,18 +1218,16 @@ Kinetic.Stage.prototype = { _detectEvent: function(shape, evt) { var isDragging = Kinetic.GlobalObject.drag.moving; var backstageLayer = this.backstageLayer; - var backstageLayerContext = backstageLayer.getContext(); var go = Kinetic.GlobalObject; var pos = this.getUserPosition(); var el = shape.eventListeners; - shape._draw(backstageLayer); if(this.targetShape && shape.id === this.targetShape.id) { this.targetFound = true; } - if(shape.visible && pos !== undefined && backstageLayerContext.isPointInPath(pos.x, pos.y)) { + if(shape.visible && pos !== undefined && shape.isPointInShape(backstageLayer,pos)) { // handle onmousedown if(!isDragging && this.mouseDown) { this.mouseDown = false; @@ -1860,6 +1858,14 @@ Kinetic.Shape = function(config) { * Shape methods */ Kinetic.Shape.prototype = { + /** + * isPointInShape + */ + isPointInShape: function(backstageLayer,pos){ + var backstageLayerContext = backstageLayer.getContext(); + this._draw(backstageLayer); + return backstageLayerContext.isPointInPath(pos.x,pos.y); + }, /** * get layer context where the shape is being drawn. When * the shape is being rendered, .getContext() returns the context of the diff --git a/src/Shape.js b/src/Shape.js index cd6dade8..969114c2 100644 --- a/src/Shape.js +++ b/src/Shape.js @@ -31,6 +31,14 @@ Kinetic.Shape = function(config) { * Shape methods */ Kinetic.Shape.prototype = { + /** + * isPointInShape + */ + isPointInShape: function(backstageLayer,pos){ + var backstageLayerContext = backstageLayer.getContext(); + this._draw(backstageLayer); + return backstageLayerContext.isPointInPath(pos.x,pos.y); + }, /** * get layer context where the shape is being drawn. When * the shape is being rendered, .getContext() returns the context of the diff --git a/src/Stage.js b/src/Stage.js index 559137d5..a15eac3d 100644 --- a/src/Stage.js +++ b/src/Stage.js @@ -238,18 +238,16 @@ Kinetic.Stage.prototype = { _detectEvent: function(shape, evt) { var isDragging = Kinetic.GlobalObject.drag.moving; var backstageLayer = this.backstageLayer; - var backstageLayerContext = backstageLayer.getContext(); var go = Kinetic.GlobalObject; var pos = this.getUserPosition(); var el = shape.eventListeners; - shape._draw(backstageLayer); if(this.targetShape && shape.id === this.targetShape.id) { this.targetFound = true; } - if(shape.visible && pos !== undefined && backstageLayerContext.isPointInPath(pos.x, pos.y)) { + if(shape.visible && pos !== undefined && shape.isPointInShape(backstageLayer,pos)) { // handle onmousedown if(!isDragging && this.mouseDown) { this.mouseDown = false;