added support for cached node with transformed ancestors

This commit is contained in:
Eric Rowell
2013-12-29 21:40:37 -08:00
parent c39726101f
commit a47726eb2f
3 changed files with 88 additions and 8 deletions

View File

@@ -265,7 +265,7 @@
clipWidth = this.getClipWidth(),
clipHeight = this.getClipHeight(),
hasClip = clipWidth && clipHeight,
context, clipX, clipY;
clipX, clipY;
if (hasClip) {
clipX = this.getClipX();

View File

@@ -984,17 +984,22 @@
return this._getCache(ABSOLUTE_TRANSFORM, this._getAbsoluteTransform);
},
_getAbsoluteTransform: function() {
// absolute transform
var am = new Kinetic.Transform(),
m;
var at = new Kinetic.Transform(),
transformsEnabled, trans;
// start with stage and traverse downwards to self
this._eachAncestorReverse(function(node) {
if (node.transformsEnabled() === 'all') {
m = node.getTransform();
am.multiply(m);
transformsEnabled = node.transformsEnabled();
trans = node.getTransform();
if (transformsEnabled === 'all') {
at.multiply(trans);
}
else if (transformsEnabled === 'position') {
at.translate(node.x(), node.y());
}
}, true);
return am;
return at;
},
/**
* get transform of the node