mirror of
https://github.com/konvajs/konva.git
synced 2025-06-28 15:23:44 +08:00
event simulation now correctly bubbles
This commit is contained in:
parent
e7699a588f
commit
440c3ac279
5
dist/kinetic-core.js
vendored
5
dist/kinetic-core.js
vendored
@ -1014,10 +1014,7 @@ Kinetic.Node.prototype = {
|
|||||||
* @param {String} eventType
|
* @param {String} eventType
|
||||||
*/
|
*/
|
||||||
simulate: function(eventType) {
|
simulate: function(eventType) {
|
||||||
var el = this.eventListeners[eventType];
|
this._handleEvent(eventType, {});
|
||||||
for(var n = 0; n < el.length; n++) {
|
|
||||||
el[n].handler.call(this);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* set center offset
|
* set center offset
|
||||||
|
4
dist/kinetic-core.min.js
vendored
4
dist/kinetic-core.min.js
vendored
File diff suppressed because one or more lines are too long
@ -651,10 +651,7 @@ Kinetic.Node.prototype = {
|
|||||||
* @param {String} eventType
|
* @param {String} eventType
|
||||||
*/
|
*/
|
||||||
simulate: function(eventType) {
|
simulate: function(eventType) {
|
||||||
var el = this.eventListeners[eventType];
|
this._handleEvent(eventType, {});
|
||||||
for(var n = 0; n < el.length; n++) {
|
|
||||||
el[n].handler.call(this);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* set center offset
|
* set center offset
|
||||||
|
@ -3576,15 +3576,53 @@ Test.prototype.tests = {
|
|||||||
circle.on('click', function() {
|
circle.on('click', function() {
|
||||||
foo = 'bar';
|
foo = 'bar';
|
||||||
|
|
||||||
|
/*
|
||||||
var evt = window.event;
|
var evt = window.event;
|
||||||
var rightClick = evt.which ? evt.which == 3 : evt.button == 2;
|
var rightClick = evt.which ? evt.which == 3 : evt.button == 2;
|
||||||
console.log(rightClick);
|
console.log(rightClick);
|
||||||
|
*/
|
||||||
});
|
});
|
||||||
|
|
||||||
circle.simulate('click');
|
circle.simulate('click');
|
||||||
|
|
||||||
test(foo === 'bar', 'foo should equal bar');
|
test(foo === 'bar', 'foo should equal bar');
|
||||||
},
|
},
|
||||||
|
'NODE - simulate event bubble': function(containerId) {
|
||||||
|
var stage = new Kinetic.Stage({
|
||||||
|
container: containerId,
|
||||||
|
width: 578,
|
||||||
|
height: 200
|
||||||
|
});
|
||||||
|
var layer = new Kinetic.Layer();
|
||||||
|
var circle = new Kinetic.Circle({
|
||||||
|
x: stage.getWidth() / 2,
|
||||||
|
y: stage.getHeight() / 2,
|
||||||
|
radius: 70,
|
||||||
|
fill: 'green',
|
||||||
|
stroke: 'black',
|
||||||
|
strokeWidth: 4,
|
||||||
|
name: 'myCircle'
|
||||||
|
});
|
||||||
|
|
||||||
|
stage.add(layer);
|
||||||
|
layer.add(circle);
|
||||||
|
layer.draw();
|
||||||
|
|
||||||
|
var clicks = [];
|
||||||
|
|
||||||
|
circle.on('click', function() {
|
||||||
|
clicks.push('circle');
|
||||||
|
});
|
||||||
|
|
||||||
|
layer.on('click', function() {
|
||||||
|
clicks.push('layer');
|
||||||
|
});
|
||||||
|
|
||||||
|
circle.simulate('click');
|
||||||
|
|
||||||
|
test(clicks[0] === 'circle', 'circle event should be fired first');
|
||||||
|
test(clicks[1] === 'layer', 'layer event should be fired second');
|
||||||
|
},
|
||||||
'STAGE - add layer then shape': function(containerId) {
|
'STAGE - add layer then shape': function(containerId) {
|
||||||
var stage = new Kinetic.Stage({
|
var stage = new Kinetic.Stage({
|
||||||
container: containerId,
|
container: containerId,
|
||||||
|
Loading…
Reference in New Issue
Block a user