mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-09 06:12:34 -05:00
Simplifications in Item#isDescendant & Item#isAncestor.
This commit is contained in:
parent
55fc2bc99c
commit
0700c51a85
1 changed files with 4 additions and 6 deletions
|
@ -375,11 +375,10 @@ var Item = this.Item = Base.extend({
|
||||||
* @return {@true if it is inside the specified item}
|
* @return {@true if it is inside the specified item}
|
||||||
*/
|
*/
|
||||||
isDescendant: function(item) {
|
isDescendant: function(item) {
|
||||||
var parent = this.parent;
|
var parent = this;
|
||||||
while (parent) {
|
while (parent = parent.parent) {
|
||||||
if (parent == item)
|
if (parent == item)
|
||||||
return true;
|
return true;
|
||||||
parent = parent.parent;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
@ -400,11 +399,10 @@ var Item = this.Item = Base.extend({
|
||||||
* @return {@true if the item is an ancestor of the specified item}
|
* @return {@true if the item is an ancestor of the specified item}
|
||||||
*/
|
*/
|
||||||
isAncestor: function(item) {
|
isAncestor: function(item) {
|
||||||
var parent = item.parent;
|
var parent = item;
|
||||||
while (parent) {
|
while (parent = parent.parent) {
|
||||||
if (parent == this)
|
if (parent == this)
|
||||||
return true;
|
return true;
|
||||||
parent = parent.parent;
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue