no longer auto clearing shape data. added new shape.clearData() method instead

This commit is contained in:
Eric Rowell 2012-04-08 20:25:31 -07:00
parent 30e8973956
commit 63c8dde6d5
4 changed files with 48 additions and 46 deletions

13
dist/kinetic-core.js vendored
View File

@ -2166,7 +2166,7 @@ Kinetic.Shape.prototype = {
/**
* save shape data when using pixel detection.
*/
save: function() {
saveData: function() {
var stage = this.getStage();
var w = stage.attrs.width;
var h = stage.attrs.height;
@ -2180,6 +2180,12 @@ Kinetic.Shape.prototype = {
var imageData = bufferLayerContext.getImageData(0, 0, w, h);
this.data = imageData.data;
},
/**
* clear shape data
*/
clearData: function() {
this.data = [];
},
/**
* draw shape
* @param {Layer} layer Layer that the shape will be drawn on
@ -2211,11 +2217,6 @@ Kinetic.Shape.prototype = {
this.drawFunc.call(this);
context.restore();
}
// clear shape data
if(this.attrs.detectionType === 'pixel') {
this.data = [];
}
},
/**
* custom isPointInPath method which can use path detection

File diff suppressed because one or more lines are too long

View File

@ -155,7 +155,7 @@ Kinetic.Shape.prototype = {
/**
* save shape data when using pixel detection.
*/
save: function() {
saveData: function() {
var stage = this.getStage();
var w = stage.attrs.width;
var h = stage.attrs.height;
@ -169,6 +169,12 @@ Kinetic.Shape.prototype = {
var imageData = bufferLayerContext.getImageData(0, 0, w, h);
this.data = imageData.data;
},
/**
* clear shape data
*/
clearData: function() {
this.data = [];
},
/**
* draw shape
* @param {Layer} layer Layer that the shape will be drawn on
@ -200,11 +206,6 @@ Kinetic.Shape.prototype = {
this.drawFunc.call(this);
context.restore();
}
// clear shape data
if(this.attrs.detectionType === 'pixel') {
this.data = [];
}
},
/**
* custom isPointInPath method which can use path detection

View File

@ -28,40 +28,40 @@ Test.prototype.tests = {
});
},
/*
'TRANSITION - all transition types': function(containerId) {
document.getElementById(containerId).style.height = '300px';
'TRANSITION - all transition types': function(containerId) {
document.getElementById(containerId).style.height = '300px';
var stage = new Kinetic.Stage({
container: containerId,
width: 578,
height: 300
});
var layer = new Kinetic.Layer();
var stage = new Kinetic.Stage({
container: containerId,
width: 578,
height: 300
});
var layer = new Kinetic.Layer();
var easings = ['linear', 'ease-in', 'ease-out', 'ease-in-out', 'back-ease-in', 'back-ease-out', 'back-ease-in-out', 'elastic-ease-in', 'elastic-ease-out', 'elastic-ease-in-out', 'bounce-ease-out', 'bounce-ease-in', 'bounce-ease-in-out', 'strong-ease-in', 'strong-ease-out', 'strong-ease-in-out'];
for(var n = 0; n < easings.length; n++) {
var rect = new Kinetic.Rect({
x: 10,
y: 10 + (n * 200 / easings.length),
width: 100,
height: 10,
fill: 'green',
stroke: 'black',
strokeWidth: 2
});
var easings = ['linear', 'ease-in', 'ease-out', 'ease-in-out', 'back-ease-in', 'back-ease-out', 'back-ease-in-out', 'elastic-ease-in', 'elastic-ease-out', 'elastic-ease-in-out', 'bounce-ease-out', 'bounce-ease-in', 'bounce-ease-in-out', 'strong-ease-in', 'strong-ease-out', 'strong-ease-in-out'];
for(var n = 0; n < easings.length; n++) {
var rect = new Kinetic.Rect({
x: 10,
y: 10 + (n * 200 / easings.length),
width: 100,
height: 10,
fill: 'green',
stroke: 'black',
strokeWidth: 2
});
layer.add(rect);
layer.add(rect);
rect.transitionTo({
duration: 2,
width: 500,
easing: easings[n]
});
}
rect.transitionTo({
duration: 2,
width: 500,
easing: easings[n]
});
}
stage.add(layer);
},
*/
stage.add(layer);
},
*/
'TRANSITION - transition callback': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
@ -679,7 +679,7 @@ Test.prototype.tests = {
});
darth.on('dragend', function() {
this.save();
this.saveData();
});
layer.add(darth);
@ -723,13 +723,13 @@ Test.prototype.tests = {
});
star.on('dragend', function() {
this.save();
this.saveData();
});
layer.add(star);
stage.add(layer);
star.save();
star.saveData();
};
imageObj.src = '../lion.png';
},