mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-03 19:45:44 -05:00
Fix Item#insertAbove(item) & Item#insertBelow(item). Closes #81
This commit is contained in:
parent
f010850f0a
commit
08c02a66f1
1 changed files with 8 additions and 4 deletions
|
@ -1169,8 +1169,10 @@ function(name) {
|
|||
* @return {Boolean} {@true it was inserted}
|
||||
*/
|
||||
insertAbove: function(item) {
|
||||
return item._parent && item._parent.insertChild(
|
||||
item._index + 1, this);
|
||||
var index = item._index;
|
||||
if (item._parent == this._parent && index < this._index)
|
||||
index++;
|
||||
return item._parent.insertChild(index, this);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -1180,8 +1182,10 @@ function(name) {
|
|||
* @return {Boolean} {@true it was inserted}
|
||||
*/
|
||||
insertBelow: function(item) {
|
||||
return item._parent && item._parent.insertChild(
|
||||
item._index - 1, this);
|
||||
var index = item._index;
|
||||
if (item._parent == this._parent && index > this._index)
|
||||
index--;
|
||||
return item._parent.insertChild(index, this);
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue