mirror of
https://github.com/scratchfoundation/paper.js.git
synced 2025-03-13 16:33:28 -04:00
Have Base.splice() delete the indices of removed items.
This commit is contained in:
parent
31be916c4f
commit
9c97e44207
1 changed files with 5 additions and 4 deletions
|
@ -53,9 +53,8 @@ Base.inject({
|
|||
append = index === undefined;
|
||||
index = append ? list.length : index;
|
||||
// Update _index on the items to be added first.
|
||||
for (var i = 0; i < amount; i++) {
|
||||
for (var i = 0; i < amount; i++)
|
||||
items[i]._index = index + i;
|
||||
}
|
||||
if (append) {
|
||||
// Append them all at the end by using push
|
||||
list.push.apply(list, items);
|
||||
|
@ -67,10 +66,12 @@ Base.inject({
|
|||
if (items)
|
||||
args.push.apply(args, items);
|
||||
var removed = list.splice.apply(list, args);
|
||||
// Delete the indices of the removed items
|
||||
for (var i = 0, l = removed.length; i < l; i++)
|
||||
delete removed[i]._index;
|
||||
// Adjust the indices of the items above.
|
||||
for (var i = index + amount, l = list.length; i < l; i++) {
|
||||
for (var i = index + amount, l = list.length; i < l; i++)
|
||||
list[i]._index = i;
|
||||
}
|
||||
return removed;
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue