added extensible isPointInPath

This commit is contained in:
Yusuf Safak Bayram 2012-03-22 23:43:14 +02:00 committed by Eric Rowell
parent 540670ba8b
commit 79c778ebff
3 changed files with 18 additions and 6 deletions

12
dist/kinetic-core.js vendored
View File

@ -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

View File

@ -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

View File

@ -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;