Skip to content

Commit

Permalink
Merge pull request SortableJS#605 from 4imble/master
Browse files Browse the repository at this point in the history
Fix to knockout sorting when dragging item index 1 to 0.
  • Loading branch information
RubaXa committed Oct 14, 2015
2 parents 282e459 + 5bbabe7 commit a531e51
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions knockout-sortable.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,11 @@
newIndex = e.newIndex;

if (e.item.previousElementSibling)
{
newIndex = fromArray.indexOf(ko.dataFor(e.item.previousElementSibling));
if (originalIndex > newIndex)
newIndex = newIndex + 1;
if (originalIndex > newIndex)
newIndex = newIndex + 1;
}

//Remove sortables "unbound" element
e.item.parentNode.removeChild(e.item);
Expand Down

0 comments on commit a531e51

Please sign in to comment.