From 630135cfdc4c1200a0aa5afa6156d012695526a6 Mon Sep 17 00:00:00 2001 From: Gayuk Ivan Date: Tue, 19 Jun 2018 13:41:23 +0300 Subject: [PATCH] Update knockout-sortable.js --- knockout-sortable.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/knockout-sortable.js b/knockout-sortable.js index fedcff7..3c9b99f 100644 --- a/knockout-sortable.js +++ b/knockout-sortable.js @@ -138,7 +138,11 @@ // drop an item above the 3rd visible item, but the 2nd visible item // has an actual index of 5. if (e.item.previousElementSibling) { - newIndex = to().indexOf(ko.dataFor(e.item.previousElementSibling)) + 1; + newIndex = to().indexOf(ko.dataFor(e.item.previousElementSibling)); + + if (newIndex < originalIndex) { + newIndex++; + } } // Remove sortables "unbound" element