Kinetic.Line detection type is now defaulted to pixel since this is the expected detection strategy

This commit is contained in:
Eric Rowell 2012-05-12 15:45:04 -07:00
parent 51258531bf
commit 502115fad7
5 changed files with 30 additions and 48 deletions

View File

@ -3609,9 +3609,9 @@ Kinetic.Text.prototype = {
* will be no associated context. Will have to create
* a dummy context
*/
if (!context) {
var dummyCanvas = document.createElement('canvas');
context = dummyCanvas.getContext('2d');
if(!context) {
var dummyCanvas = document.createElement('canvas');
context = dummyCanvas.getContext('2d');
}
context.save();
@ -3640,7 +3640,8 @@ Kinetic.Line = function(config) {
this.setDefaultAttrs({
points: [],
lineCap: 'butt',
dashArray: []
dashArray: [],
detectionType: 'pixel'
});
this.shapeType = "Line";

File diff suppressed because one or more lines are too long

View File

@ -11,7 +11,8 @@ Kinetic.Line = function(config) {
this.setDefaultAttrs({
points: [],
lineCap: 'butt',
dashArray: []
dashArray: [],
detectionType: 'pixel'
});
this.shapeType = "Line";

View File

@ -240,9 +240,9 @@ Kinetic.Text.prototype = {
* will be no associated context. Will have to create
* a dummy context
*/
if (!context) {
var dummyCanvas = document.createElement('canvas');
context = dummyCanvas.getContext('2d');
if(!context) {
var dummyCanvas = document.createElement('canvas');
context = dummyCanvas.getContext('2d');
}
context.save();

View File

@ -1219,10 +1219,11 @@ Test.prototype.tests = {
}, {
x: 340,
y: 23
}, {
x: 500,
y: 109
}];
}
/*, {
x: 500,
y: 109
}*/];
var line = new Kinetic.Line({
points: points,
@ -1233,9 +1234,17 @@ Test.prototype.tests = {
draggable: true
});
// test that default detection type is pixel
test(line.getDetectionType() === 'pixel', 'dection type should be pixel');
layer.add(line);
stage.add(layer);
line.saveData();
line.on('dragend', function() {
line.saveData();
});
},
'SHAPES - add dashed line': function(containerId) {
var stage = new Kinetic.Stage({
@ -1936,8 +1945,8 @@ Test.prototype.tests = {
verticalAlign: 'middle'
});
// test text width before adding it to stage
test(text.getTextWidth() > 0, 'text width should have a value');
// test text width before adding it to stage
test(text.getTextWidth() > 0, 'text width should have a value');
layer.add(text);
stage.add(layer);