fixed up group drag and drop

This commit is contained in:
Eric Rowell
2012-12-31 01:47:49 -08:00
parent 83bf1740a6
commit 206f7bf8d0
4 changed files with 10 additions and 14 deletions

View File

@@ -195,10 +195,10 @@
},
_applyAncestorTransforms: function(node) {
var context = this.context;
node.eachAncestorReverse(function(no) {
node._eachAncestorReverse(function(no) {
var t = no.getTransform(), m = t.getMatrix();
context.transform(m[0], m[1], m[2], m[3], m[4], m[5]);
});
}, true);
}
};

View File

@@ -38,7 +38,7 @@
dd.prevParent = this.getParent();
// re-construct node tree
this.eachAncestorReverse(function(node) {
this._eachAncestorReverse(function(node) {
if(node.nodeType === 'Layer') {
dd.topLayer = new Kinetic.Layer({
x: node.getX(),

View File

@@ -436,17 +436,13 @@
getRotationDeg: function() {
return Kinetic.Type._radToDeg(this.getRotation());
},
/**
* iterate through ancestors in reverse
* @name eachAncestorReverse
* @methodOf Kinetic.Node.prototype
* @param {Function} func function is passed a node on each iteration
*/
eachAncestorReverse: function(func) {
_eachAncestorReverse: function(func, includeSelf) {
var family = [], parent = this.getParent();
// build family by traversing ancestors
family.unshift(this);
if(includeSelf) {
family.unshift(this);
}
while(parent) {
family.unshift(parent);
parent = parent.parent;
@@ -671,10 +667,10 @@
// absolute transform
var am = new Kinetic.Transform();
this.eachAncestorReverse(function(node) {
this._eachAncestorReverse(function(node) {
var m = node.getTransform();
am.multiply(m);
});
}, true);
return am;
},
/**

View File

@@ -258,7 +258,7 @@ Test.Modules.NODE = {
clone.simulate('click');
test(clicks.toString() === 'myRect,rectClone', 'click order should be myRect followed by rectClone');
},
'*clone a group': function(containerId) {
'clone a group': function(containerId) {
var stage = new Kinetic.Stage({
container: containerId,
width: 578,