mirror of
https://github.com/konvajs/konva.git
synced 2026-03-03 16:58:33 +08:00
added support for event bubble cancelation
This commit is contained in:
@@ -158,8 +158,7 @@ Kinetic.GlobalObject = {
|
||||
this.isAnimating = true;
|
||||
that._animationLoop();
|
||||
}
|
||||
else
|
||||
if(this.isAnimating && !this._isaCanvasAnimating()) {
|
||||
else if(this.isAnimating && !this._isaCanvasAnimating()) {
|
||||
this.isAnimating = false;
|
||||
this.frame.lastTime = 0;
|
||||
}
|
||||
|
||||
@@ -541,15 +541,11 @@ Kinetic.Node.prototype = {
|
||||
}
|
||||
}
|
||||
|
||||
if(obj.parent.className !== 'Stage') {
|
||||
// simulate event bubbling
|
||||
if(!evt.cancelBubble && obj.parent.className !== 'Stage') {
|
||||
handle(obj.parent);
|
||||
}
|
||||
}
|
||||
/*
|
||||
* simulate bubbling by handling node events
|
||||
* first, followed by group events, followed
|
||||
* by layer events
|
||||
*/
|
||||
handle(this);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -16,8 +16,7 @@ Kinetic.Shape = function(config) {
|
||||
if(config.stroke === undefined) {
|
||||
config.stroke = 'black';
|
||||
}
|
||||
else
|
||||
if(config.strokeWidth === undefined) {
|
||||
else if(config.strokeWidth === undefined) {
|
||||
config.strokeWidth = 2;
|
||||
}
|
||||
}
|
||||
|
||||
23
src/Stage.js
23
src/Stage.js
@@ -285,8 +285,7 @@ Kinetic.Stage.prototype = {
|
||||
return true;
|
||||
}
|
||||
// handle onmouseup & onclick
|
||||
else
|
||||
if(this.mouseUp) {
|
||||
else if(this.mouseUp) {
|
||||
this.mouseUp = false;
|
||||
shape._handleEvents('onmouseup', evt);
|
||||
|
||||
@@ -312,8 +311,7 @@ Kinetic.Stage.prototype = {
|
||||
}
|
||||
|
||||
// handle touchstart
|
||||
else
|
||||
if(this.touchStart) {
|
||||
else if(this.touchStart) {
|
||||
this.touchStart = false;
|
||||
shape._handleEvents('touchstart', evt);
|
||||
|
||||
@@ -333,23 +331,20 @@ Kinetic.Stage.prototype = {
|
||||
}
|
||||
|
||||
// handle touchend
|
||||
else
|
||||
if(this.touchEnd) {
|
||||
else if(this.touchEnd) {
|
||||
this.touchEnd = false;
|
||||
shape._handleEvents('touchend', evt);
|
||||
return true;
|
||||
}
|
||||
|
||||
// handle touchmove
|
||||
else
|
||||
if(!isDragging && el.touchmove) {
|
||||
else if(!isDragging && el.touchmove) {
|
||||
shape._handleEvents('touchmove', evt);
|
||||
return true;
|
||||
}
|
||||
|
||||
//this condition is used to identify a new target shape.
|
||||
else
|
||||
if(!isDragging && (!this.targetShape || (!this.targetFound && shape.id !== this.targetShape.id))) {
|
||||
else if(!isDragging && (!this.targetShape || (!this.targetFound && shape.id !== this.targetShape.id))) {
|
||||
/*
|
||||
* check if old target has an onmouseout event listener
|
||||
*/
|
||||
@@ -370,15 +365,13 @@ Kinetic.Stage.prototype = {
|
||||
}
|
||||
|
||||
// handle onmousemove
|
||||
else
|
||||
if(!isDragging) {
|
||||
else if(!isDragging) {
|
||||
shape._handleEvents('onmousemove', evt);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// handle mouseout condition
|
||||
else
|
||||
if(!isDragging && this.targetShape && this.targetShape.id === shape.id) {
|
||||
else if(!isDragging && this.targetShape && this.targetShape.id === shape.id) {
|
||||
this.targetShape = undefined;
|
||||
shape._handleEvents('onmouseout', evt);
|
||||
return true;
|
||||
@@ -402,7 +395,7 @@ Kinetic.Stage.prototype = {
|
||||
}
|
||||
}
|
||||
else {
|
||||
this._traverseChildren(child);
|
||||
this._traverseChildren(child, evt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,4 +41,4 @@ Kinetic.Polygon.prototype = {
|
||||
};
|
||||
|
||||
// extend Shape
|
||||
Kinetic.GlobalObject.extend(Kinetic.Polygon, Kinetic.Shape);
|
||||
Kinetic.GlobalObject.extend(Kinetic.Polygon, Kinetic.Shape);
|
||||
|
||||
@@ -70,4 +70,4 @@ Kinetic.RegularPolygon.prototype = {
|
||||
};
|
||||
|
||||
// extend Shape
|
||||
Kinetic.GlobalObject.extend(Kinetic.RegularPolygon, Kinetic.Shape);
|
||||
Kinetic.GlobalObject.extend(Kinetic.RegularPolygon, Kinetic.Shape);
|
||||
|
||||
@@ -70,4 +70,4 @@ Kinetic.Star.prototype = {
|
||||
}
|
||||
};
|
||||
// extend Shape
|
||||
Kinetic.GlobalObject.extend(Kinetic.Star, Kinetic.Shape);
|
||||
Kinetic.GlobalObject.extend(Kinetic.Star, Kinetic.Shape);
|
||||
|
||||
@@ -15,8 +15,7 @@ Kinetic.Text = function(config) {
|
||||
if(config.textStroke === undefined) {
|
||||
config.textStroke = 'black';
|
||||
}
|
||||
else
|
||||
if(config.textStrokeWidth === undefined) {
|
||||
else if(config.textStrokeWidth === undefined) {
|
||||
config.textStrokeWidth = 2;
|
||||
}
|
||||
}
|
||||
@@ -80,8 +79,7 @@ Kinetic.Text = function(config) {
|
||||
if(this.textStroke === undefined) {
|
||||
this.textStroke = 'black';
|
||||
}
|
||||
else
|
||||
if(this.textStrokeWidth === undefined) {
|
||||
else if(this.textStrokeWidth === undefined) {
|
||||
this.textStrokeWidth = 2;
|
||||
}
|
||||
context.lineWidth = this.textStrokeWidth;
|
||||
|
||||
Reference in New Issue
Block a user