mirror of
https://github.com/konvajs/konva.git
synced 2025-09-18 18:27:58 +08:00
leveraged new eachAncestorReverse() method where possible
This commit is contained in:
35
src/Node.js
35
src/Node.js
@@ -440,8 +440,7 @@
|
||||
* iterate through ancestors in reverse
|
||||
* @name eachAncestorReverse
|
||||
* @methodOf Kinetic.Node.prototype
|
||||
* @param {Function} func function is passed two arguments, a node and
|
||||
* the iterator integer
|
||||
* @param {Function} func function is passed a node on each iteration
|
||||
*/
|
||||
eachAncestorReverse: function(func) {
|
||||
var family = [], parent = this.getParent();
|
||||
@@ -455,21 +454,7 @@
|
||||
|
||||
var len = family.length;
|
||||
for(var n = 0; n < len; n++) {
|
||||
func(family[n], n);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* iterate through ancestors
|
||||
* @name eachAncestor
|
||||
* @methodOf Kinetic.Node.prototype
|
||||
* @param {Function} func function is passed two arguments, a node and
|
||||
* the iterator integer
|
||||
*/
|
||||
eachAncestor: function(func) {
|
||||
var family = [], parent = this.getParent(), n = 0;
|
||||
while(parent) {
|
||||
func(parent, n++);
|
||||
parent = parent.parent;
|
||||
func(family[n]);
|
||||
}
|
||||
},
|
||||
/**
|
||||
@@ -686,22 +671,10 @@
|
||||
// absolute transform
|
||||
var am = new Kinetic.Transform();
|
||||
|
||||
var family = [];
|
||||
var parent = this.parent;
|
||||
|
||||
family.unshift(this);
|
||||
while(parent) {
|
||||
family.unshift(parent);
|
||||
parent = parent.parent;
|
||||
}
|
||||
|
||||
var len = family.length;
|
||||
for(var n = 0; n < len; n++) {
|
||||
var node = family[n];
|
||||
this.eachAncestorReverse(function(node) {
|
||||
var m = node.getTransform();
|
||||
am.multiply(m);
|
||||
}
|
||||
|
||||
});
|
||||
return am;
|
||||
},
|
||||
/**
|
||||
|
Reference in New Issue
Block a user