mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-01-20 22:39:50 -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}
|
* @return {Boolean} {@true it was inserted}
|
||||||
*/
|
*/
|
||||||
insertAbove: function(item) {
|
insertAbove: function(item) {
|
||||||
return item._parent && item._parent.insertChild(
|
var index = item._index;
|
||||||
item._index + 1, this);
|
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}
|
* @return {Boolean} {@true it was inserted}
|
||||||
*/
|
*/
|
||||||
insertBelow: function(item) {
|
insertBelow: function(item) {
|
||||||
return item._parent && item._parent.insertChild(
|
var index = item._index;
|
||||||
item._index - 1, this);
|
if (item._parent == this._parent && index > this._index)
|
||||||
|
index--;
|
||||||
|
return item._parent.insertChild(index, this);
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue