Skip to content

Commit 5af4d5c

Browse files
authored
Merge pull request #2 from IvanHaiuk/master
fixed incorrect behavior of previous element sibling SortableJS#11
2 parents ba86ae0 + 630135c commit 5af4d5c

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

knockout-sortable.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,11 @@
140140
// drop an item above the 3rd visible item, but the 2nd visible item
141141
// has an actual index of 5.
142142
if (e.item.previousElementSibling) {
143-
newIndex = to().indexOf(ko.dataFor(e.item.previousElementSibling)) + 1;
143+
newIndex = to().indexOf(ko.dataFor(e.item.previousElementSibling));
144+
145+
if (newIndex < originalIndex) {
146+
newIndex++;
147+
}
144148
}
145149

146150
// Remove sortables "unbound" element

0 commit comments

Comments
 (0)