Browse Source

Fix to knockout sorting when dragging item index 1 to 0.

The items would not swap positions when you dragged item with index 1 to
the top of the stack at index 0.
pull/605/head
4imble 9 years ago
parent
commit
5bbabe7c08
  1. 6
      knockout-sortable.js

6
knockout-sortable.js

@ -84,9 +84,11 @@
newIndex = e.newIndex; newIndex = e.newIndex;
if (e.item.previousElementSibling) if (e.item.previousElementSibling)
{
newIndex = fromArray.indexOf(ko.dataFor(e.item.previousElementSibling)); newIndex = fromArray.indexOf(ko.dataFor(e.item.previousElementSibling));
if (originalIndex > newIndex) if (originalIndex > newIndex)
newIndex = newIndex + 1; newIndex = newIndex + 1;
}
//Remove sortables "unbound" element //Remove sortables "unbound" element
e.item.parentNode.removeChild(e.item); e.item.parentNode.removeChild(e.item);

Loading…
Cancel
Save