mirror of
https://github.com/konvajs/konva.git
synced 2025-04-05 20:48:28 +08:00
fix: avoid moveToTop if node is on top
This commit is contained in:
parent
bdcfb2455f
commit
1cb224d7ee
14
src/Node.ts
14
src/Node.ts
@ -1324,11 +1324,15 @@ export abstract class Node<Config extends NodeConfig = NodeConfig> {
|
||||
Util.warn('Node has no parent. moveToTop function is ignored.');
|
||||
return false;
|
||||
}
|
||||
var index = this.index;
|
||||
this.parent.children.splice(index, 1);
|
||||
this.parent.children.push(this);
|
||||
this.parent._setChildrenIndices();
|
||||
return true;
|
||||
var index = this.index,
|
||||
len = this.parent.getChildren().length;
|
||||
if (index < len - 1) {
|
||||
this.parent.children.splice(index, 1);
|
||||
this.parent.children.push(this);
|
||||
this.parent._setChildrenIndices();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* move node up
|
||||
|
Loading…
Reference in New Issue
Block a user