SortableJS / knockout-sortablejs

A Knockout.js binding to SortableJS.
21 stars 19 forks source link

Fix issue with drag and drop index positioning #1

Open jfrei opened 8 years ago

jfrei commented 8 years ago

Note: Has not been tested with dragging/dropping with more than one collection.

NoOutlet commented 8 years ago

Actually, I'm finding that newIndex is always 0 at that point and so the fix isn't working for me, but I'm glad that someone is looking into it.

This seems to work for me, but isn't pretty:

140                 if (e.item.previousElementSibling) {
141                     newIndex = to().indexOf(ko.dataFor(e.item.previousElementSibling));
142                     newIndex += (newIndex > originalIndex ? 0 : 1);
143                 }
jfrei commented 8 years ago

I've confirmed the code you've pasted above works and it looks better than what I've done :+1: Also, quick thanks for the plugin, saved me lots of time :)

matthewnitschke commented 7 years ago

Yes! Been having the same problem and this fixed it, thank you. Can this please be merged into the master?

crystalfp commented 3 years ago

Yes, please! Merge it. It solved my last problem with knockout-sortable.