Commit 21e21c93b334c79676b367cacbd519536c968bd2
mapped-array: fix move
Matt McKegg committed on 9/11/2016, 9:59:01 AMParent: 13c491b3bb6c89a2546fd4301ea7396625a55e9d
Files changed
mapped-array.js | changed |
mapped-array.js | ||
---|---|---|
@@ -36,13 +36,17 @@ | ||
36 | 36 | var currentIndex = obs.indexOf(mappedItem) |
37 | 37 | if (~currentIndex) { |
38 | 38 | var item = list.get(currentIndex) |
39 | 39 | if (currentIndex < targetIndex) { |
40 | - list.insert(item, targetIndex + 1) | |
41 | - list.deleteAt(currentIndex) | |
42 | - } else { | |
43 | - list.insert(item, targetIndex) | |
44 | - list.deleteAt(currentIndex) | |
40 | + list.transaction(function () { | |
41 | + list.insert(item, targetIndex + 1) | |
42 | + list.deleteAt(currentIndex) | |
43 | + }) | |
44 | + } else if (currentIndex > targetIndex) { | |
45 | + list.transaction(function () { | |
46 | + list.insert(item, targetIndex) | |
47 | + list.deleteAt(currentIndex + 1) | |
48 | + }) | |
45 | 49 | } |
46 | 50 | } |
47 | 51 | } |
48 | 52 |
Built with git-ssb-web