Kinetic.Text events now work property

This commit is contained in:
Eric Rowell
2013-02-11 22:55:24 -08:00
parent 5d3180aee5
commit 5ac8142f82
3 changed files with 59 additions and 6 deletions

View File

@@ -364,7 +364,7 @@
var context = this.context;
context.save();
context.fillStyle = '#' + shape.colorKey;
shape._fillFunc(context);
shape._fillFuncHit(context);
context.restore();
},
_stroke: function(shape) {
@@ -374,7 +374,7 @@
context.save();
context.lineWidth = strokeWidth || 2;
context.strokeStyle = '#' + shape.colorKey;
shape._strokeFunc(context);
shape._strokeFuncHit(context);
context.restore();
}
}

View File

@@ -17,6 +17,12 @@
function _strokeFunc(context) {
context.stroke();
}
function _fillFuncHit(context) {
context.fill();
}
function _strokeFuncHit(context) {
context.stroke();
}
Kinetic.Shape.prototype = {
_initShape: function(config) {
@@ -31,6 +37,8 @@
this.nodeType = 'Shape';
this._fillFunc = _fillFunc;
this._strokeFunc = _strokeFunc;
this._fillFuncHit = _fillFuncHit;
this._strokeFuncHit = _strokeFuncHit;
// set colorKey
var shapes = Kinetic.Global.shapes;

View File

@@ -23,9 +23,9 @@ Test.Modules.DD = {
layer.add(circle);
stage.add(layer);
function remove() {
circle.remove();
circle.remove();
layer.draw();
warn(layer.toDataURL() === dataUrls['cleared'], 'canvas should be cleared after removing shape onclick');
}
@@ -88,11 +88,10 @@ Test.Modules.DD = {
// test set draggable false after drag end
//this.setDraggable(false);
});
circle.on('mouseup', function() {
console.log('mousup')
});
warn(layer.toDataURL() === dataUrls['drag circle before'], 'start data url is incorrect');
/*
* simulate drag and drop
@@ -271,6 +270,52 @@ Test.Modules.DD = {
};
Test.Modules.EVENT = {
'*text events': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,
height: 200,
throttle: 999
});
var layer = new Kinetic.Layer();
var text = new Kinetic.Text({
x: 290,
y: 111,
fontFamily: 'Calibri',
fontSize: 30,
fill: 'red',
text: 'Testing 123',
draggable: true
});
var click = false
text.on('click', function() {
click = true;
});
layer.add(text);
stage.add(layer);
var top = stage.content.getBoundingClientRect().top;
showHit(layer);
stage._mousedown({
clientX: 291,
clientY: 112 + top
});
stage._mouseup({
clientX: 291,
clientY: 112 + top
});
// end drag is tied to document mouseup and touchend event
// which can't be simulated. call _endDrag manually
Kinetic.DD._endDrag();
test(click, 'click event should have been fired when mousing down and then up on text');
},
'modify fill stroke and stroke width on hover with circle': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,