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.');
|
Util.warn('Node has no parent. moveToTop function is ignored.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var index = this.index;
|
var index = this.index,
|
||||||
this.parent.children.splice(index, 1);
|
len = this.parent.getChildren().length;
|
||||||
this.parent.children.push(this);
|
if (index < len - 1) {
|
||||||
this.parent._setChildrenIndices();
|
this.parent.children.splice(index, 1);
|
||||||
return true;
|
this.parent.children.push(this);
|
||||||
|
this.parent._setChildrenIndices();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* move node up
|
* move node up
|
||||||
|
Loading…
Reference in New Issue
Block a user