This commit is contained in:
ippo615
2013-12-07 12:38:18 -05:00
41 changed files with 165 additions and 8778 deletions

View File

@@ -1,8 +1,28 @@
(function() {
var SPACE = '',
TRANSFORM_CHANGE_STR = [
'xChange.kinetic',
'yChange.kinetic',
'scaleXChange.kinetic',
'scaleYChange.kinetic',
'skewXChange.kinetic',
'skewYChange.kinetic',
'rotationChange.kinetic',
'offsetXChange.kinetic',
'offsetYChange.kinetic'
].join(SPACE);
Kinetic.Util.addMethods(Kinetic.Container, {
__init: function(config) {
this.children = new Kinetic.Collection();
Kinetic.Node.call(this, config);
this.on(TRANSFORM_CHANGE_STR, function() {
var stage = this.getStage();
if (stage) {
stage._enableNestedTransforms = true;
}
});
},
/**
* returns a {@link Kinetic.Collection} of direct descendant nodes

View File

@@ -224,7 +224,15 @@
}
},
_applyAncestorTransforms: function(shape) {
var m = shape.getAbsoluteTransform().getMatrix();
var stage = shape.getStage(),
m;
if (stage && stage._enableNestedTransforms) {
m = shape.getAbsoluteTransform().getMatrix();
}
else {
m = shape.getTransform().getMatrix();
}
this.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
},
_clip: function(container) {

View File

@@ -42,7 +42,7 @@ var Kinetic = {};
shapes: {},
listenClickTap: false,
inDblClickWindow: false,
// configurations
enableTrace: false,
traceArrMax: 100,

View File

@@ -42,7 +42,7 @@
X = 'x',
Y = 'y',
transformChangeStr = [
TRANSFORM_CHANGE_STR = [
'xChange.kinetic',
'yChange.kinetic',
'scaleXChange.kinetic',
@@ -64,7 +64,7 @@
this.setAttrs(config);
// event bindings for cache handling
this.on(transformChangeStr, function() {
this.on(TRANSFORM_CHANGE_STR, function() {
this._clearCache(TRANSFORM);
that._clearSelfAndChildrenCache(ABSOLUTE_TRANSFORM);
});
@@ -1251,7 +1251,6 @@
* @memberof Kinetic.Node.prototype
*/
getTransform: function() {
//return this._getTransform();
return this._getCache(TRANSFORM, this._getTransform);
}
});

View File

@@ -61,6 +61,7 @@
this._id = Kinetic.idCounter++;
this._buildDOM();
this._bindContentEvents();
this._enableNestedTransforms = false;
Kinetic.stages.push(this);
},
_validateAdd: function(child) {

View File

@@ -103,16 +103,10 @@
start = node.getAttr(key);
if (Kinetic.Util._isArray(end)) {
end = Kinetic.Util._getPoints(end);
diff = [];
len = end.length;
for (n=0; n<len; n++) {
startVal = start[n];
endVal = end[n];
diff.push({
x: endVal.x - startVal.x,
y: endVal.y - startVal.y
});
diff.push(end[n] - start[n]);
}
}
@@ -140,12 +134,7 @@
newVal = [];
len = start.length;
for (n=0; n<len; n++) {
startVal = start[n];
diffVal = diff[n];
newVal.push({
x: startVal.x + (diffVal.x * i),
y: startVal.y + (diffVal.y * i)
});
newVal.push(start[n] + (diff[n] * i));
}
}
else {