mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 06:31:15 +08:00
added extensible isPointInPath
This commit is contained in:
parent
540670ba8b
commit
79c778ebff
12
dist/kinetic-core.js
vendored
12
dist/kinetic-core.js
vendored
@ -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
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user