mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
currentTarget fix
This commit is contained in:
parent
7f2315fb1d
commit
2e76cfba30
10
konva.js
10
konva.js
@ -3,7 +3,7 @@
|
||||
* Konva JavaScript Framework v0.11.0
|
||||
* http://konvajs.github.io/
|
||||
* Licensed under the MIT or GPL Version 2 licenses.
|
||||
* Date: Sat Jan 02 2016
|
||||
* Date: Mon Jan 04 2016
|
||||
*
|
||||
* Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
|
||||
* Modified work Copyright (C) 2014 - 2015 by Anton Lavrenov (Konva)
|
||||
@ -3563,9 +3563,9 @@
|
||||
* node.fire('click', null, true);
|
||||
*/
|
||||
fire: function(eventType, evt, bubble) {
|
||||
evt = evt || {};
|
||||
evt.target = evt.target || this;
|
||||
// bubble
|
||||
evt = Konva.Util.cloneObject(evt || {});
|
||||
evt.currentTarget = this;
|
||||
if (bubble) {
|
||||
this._fireAndBubble(eventType, evt);
|
||||
}
|
||||
@ -4005,7 +4005,7 @@
|
||||
|
||||
// simulate event bubbling
|
||||
var stopBubble = (eventType === MOUSEENTER || eventType === MOUSELEAVE) && ((compareShape && compareShape.isAncestorOf && compareShape.isAncestorOf(this)) || !!(compareShape && compareShape.isAncestorOf));
|
||||
if(evt && !evt.cancelBubble && this.parent && this.parent.isListening() && (!stopBubble)) {
|
||||
if((evt && !evt.cancelBubble || !evt) && this.parent && this.parent.isListening() && (!stopBubble)) {
|
||||
if(compareShape && compareShape.parent) {
|
||||
this._fireAndBubble.call(this.parent, eventType, evt, compareShape.parent);
|
||||
}
|
||||
@ -4019,6 +4019,8 @@
|
||||
var events = this.eventListeners[eventType],
|
||||
i;
|
||||
|
||||
evt = Konva.Util.cloneObject(evt || {});
|
||||
evt.currentTarget = this;
|
||||
evt.type = eventType;
|
||||
|
||||
if (events) {
|
||||
|
4
konva.min.js
vendored
4
konva.min.js
vendored
File diff suppressed because one or more lines are too long
@ -1326,9 +1326,9 @@
|
||||
* node.fire('click', null, true);
|
||||
*/
|
||||
fire: function(eventType, evt, bubble) {
|
||||
evt = evt || {};
|
||||
evt.target = evt.target || this;
|
||||
// bubble
|
||||
evt = Konva.Util.cloneObject(evt || {});
|
||||
evt.currentTarget = this;
|
||||
if (bubble) {
|
||||
this._fireAndBubble(eventType, evt);
|
||||
}
|
||||
@ -1768,7 +1768,7 @@
|
||||
|
||||
// simulate event bubbling
|
||||
var stopBubble = (eventType === MOUSEENTER || eventType === MOUSELEAVE) && ((compareShape && compareShape.isAncestorOf && compareShape.isAncestorOf(this)) || !!(compareShape && compareShape.isAncestorOf));
|
||||
if(evt && !evt.cancelBubble && this.parent && this.parent.isListening() && (!stopBubble)) {
|
||||
if((evt && !evt.cancelBubble || !evt) && this.parent && this.parent.isListening() && (!stopBubble)) {
|
||||
if(compareShape && compareShape.parent) {
|
||||
this._fireAndBubble.call(this.parent, eventType, evt, compareShape.parent);
|
||||
}
|
||||
@ -1782,6 +1782,8 @@
|
||||
var events = this.eventListeners[eventType],
|
||||
i;
|
||||
|
||||
evt = Konva.Util.cloneObject(evt || {});
|
||||
evt.currentTarget = this;
|
||||
evt.type = eventType;
|
||||
|
||||
if (events) {
|
||||
|
@ -1899,12 +1899,13 @@ suite('Node', function() {
|
||||
|
||||
var fired = false;
|
||||
layer.on('click', 'Circle', function(e) {
|
||||
console.log(e);
|
||||
assert.equal(this, circle);
|
||||
assert.equal(e.currentTarget, circle);
|
||||
fired = true;
|
||||
});
|
||||
circle.fire('click', null, true);
|
||||
assert(fired, true);
|
||||
assert.equal(fired, true);
|
||||
});
|
||||
|
||||
test('complex event delegation', function() {
|
||||
@ -1935,7 +1936,7 @@ suite('Node', function() {
|
||||
fired = true;
|
||||
});
|
||||
circle.fire('click', null, true);
|
||||
assert(fired, true);
|
||||
assert.equal(fired, true);
|
||||
});
|
||||
// ======================================================
|
||||
test('move shape, group, and layer, and then get absolute position', function() {
|
||||
|
Loading…
Reference in New Issue
Block a user