mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
Merge branch 'master' of git://github.com/ericdrowell/KineticJS
This commit is contained in:
commit
386971ce70
18
src/Node.js
18
src/Node.js
@ -398,14 +398,20 @@
|
||||
}
|
||||
return this;
|
||||
},
|
||||
// some event aliases for third party integration like HammerJS
|
||||
// some event aliases for third party integration like HammerJS
|
||||
dispatchEvent: function(evt) {
|
||||
evt.target = this;
|
||||
evt.type = evt.evt.type;
|
||||
this.fire(evt.type, evt);
|
||||
var e = {
|
||||
target: this,
|
||||
type: evt.type,
|
||||
evt: evt
|
||||
};
|
||||
this.fire(evt.type, e);
|
||||
},
|
||||
addEventListener: function() {
|
||||
this.on.apply(this, arguments);
|
||||
addEventListener: function(type, handler) {
|
||||
// we to pass native event to handler
|
||||
this.on(type, function(evt){
|
||||
handler.call(this, evt.evt);
|
||||
});
|
||||
},
|
||||
/**
|
||||
* remove self from parent, but don't destroy
|
||||
|
@ -682,6 +682,14 @@
|
||||
baseEvent = types[n];
|
||||
this.content.addEventListener(baseEvent, handler, false);
|
||||
}
|
||||
},
|
||||
// currently cache function is now working for stage, because stage has no its own canvas element
|
||||
// TODO: may be it is better to cache all children layers?
|
||||
cache: function() {
|
||||
Kinetic.Util.warn('Cache function is not allowed for stage. You may use cache only for layers, groups and shapes.');
|
||||
return;
|
||||
},
|
||||
clearCache : function() {
|
||||
}
|
||||
});
|
||||
Kinetic.Util.extend(Kinetic.Stage, Kinetic.Container);
|
||||
|
@ -624,5 +624,46 @@ suite('Shape', function() {
|
||||
assert.equal(shape.fillRadialGradientEndPointY(), 0);
|
||||
assert.equal(shape.fillPatternRotation(), 0);
|
||||
});
|
||||
|
||||
// ======================================================
|
||||
test.skip('hit graph when shape cached before adding to Layer', function() {
|
||||
var stage = addStage();
|
||||
var layer = new Kinetic.Layer();
|
||||
var rect = new Kinetic.Rect({
|
||||
x: 290,
|
||||
y: 111,
|
||||
width : 50,
|
||||
height : 50,
|
||||
fill : 'black'
|
||||
});
|
||||
rect.cache();
|
||||
|
||||
var click = false;
|
||||
|
||||
rect.on('click', function() {
|
||||
click = true;
|
||||
});
|
||||
|
||||
layer.add(rect);
|
||||
stage.add(layer);
|
||||
|
||||
var top = stage.content.getBoundingClientRect().top;
|
||||
|
||||
showHit(layer);
|
||||
|
||||
stage._mousedown({
|
||||
clientX: 300,
|
||||
clientY: 120 + top
|
||||
});
|
||||
|
||||
Kinetic.DD._endDragBefore();
|
||||
stage._mouseup({
|
||||
clientX: 300,
|
||||
clientY: 120 + top
|
||||
});
|
||||
Kinetic.DD._endDragAfter({dragEndNode:rect});
|
||||
|
||||
//TODO: can't get this to pass
|
||||
assert.equal(click, true, 'click event should have been fired when mousing down and then up on rect');
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user