mirror of
https://github.com/konvajs/konva.git
synced 2025-10-15 12:34:52 +08:00
fix some stage evetns. close #627
This commit is contained in:
@@ -2076,9 +2076,10 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
|
||||
|
||||
var shouldStop =
|
||||
(eventType === MOUSEENTER || eventType === MOUSELEAVE) &&
|
||||
compareShape &&
|
||||
(this._id === compareShape._id ||
|
||||
(this.isAncestorOf && this.isAncestorOf(compareShape)));
|
||||
((compareShape &&
|
||||
(this === compareShape ||
|
||||
(this.isAncestorOf && this.isAncestorOf(compareShape)))) ||
|
||||
(this.nodeType === 'Stage' && !compareShape));
|
||||
|
||||
if (!shouldStop) {
|
||||
this._fire(eventType, evt);
|
||||
|
20
src/Stage.ts
20
src/Stage.ts
@@ -55,6 +55,7 @@ var STAGE = 'Stage',
|
||||
MAX_LAYERS_NUMBER = 5,
|
||||
EMPTY_STRING = '',
|
||||
EVENTS = [
|
||||
MOUSEENTER,
|
||||
MOUSEDOWN,
|
||||
MOUSEMOVE,
|
||||
MOUSEUP,
|
||||
@@ -287,7 +288,7 @@ export class Stage extends Container {
|
||||
* // or if you interested in shape parent:
|
||||
* var group = stage.getIntersection({x: 50, y: 50}, 'Group');
|
||||
*/
|
||||
getIntersection(pos: Vector2d, selector?: string) {
|
||||
getIntersection(pos: Vector2d, selector?: string): Shape | null {
|
||||
var layers = this.children,
|
||||
len = layers.length,
|
||||
end = len - 1,
|
||||
@@ -378,6 +379,10 @@ export class Stage extends Container {
|
||||
addEvent(this, EVENTS[n]);
|
||||
}
|
||||
}
|
||||
_mouseenter(evt) {
|
||||
this.setPointersPositions(evt);
|
||||
this._fire(MOUSEENTER, { evt: evt, target: this, currentTarget: this });
|
||||
}
|
||||
_mouseover(evt) {
|
||||
this.setPointersPositions(evt);
|
||||
this._fire(CONTENT_MOUSEOVER, { evt: evt });
|
||||
@@ -391,6 +396,17 @@ export class Stage extends Container {
|
||||
targetShape._fireAndBubble(MOUSEOUT, { evt: evt });
|
||||
targetShape._fireAndBubble(MOUSELEAVE, { evt: evt });
|
||||
this.targetShape = null;
|
||||
} else if (!DD.isDragging) {
|
||||
this._fire(MOUSELEAVE, {
|
||||
evt: evt,
|
||||
target: this,
|
||||
currentTarget: this
|
||||
});
|
||||
this._fire(MOUSEOUT, {
|
||||
evt: evt,
|
||||
target: this,
|
||||
currentTarget: this
|
||||
});
|
||||
}
|
||||
this.pointerPos = undefined;
|
||||
|
||||
@@ -402,7 +418,7 @@ export class Stage extends Container {
|
||||
return this._touchmove(evt);
|
||||
}
|
||||
this.setPointersPositions(evt);
|
||||
var shape;
|
||||
var shape: Shape;
|
||||
|
||||
if (!DD.isDragging) {
|
||||
shape = this.getIntersection(this.getPointerPosition());
|
||||
|
Reference in New Issue
Block a user