Description
Firstly, let me thank you for your time putting the code up and maintaining it! The roadmap and the next release do look very promising!
For the last two days I am evaluating the project and have come to a conclusion that there is something amiss when 'sortupdate' is dispatched.
Sortupdate fires off - per comments in the code - when either parent list has changed (makes sense) and the index of the item has changed (also makes sense). Attached to the sortupdate is this super helpful detail
object.
I was tipped off when 'sortupdate' was dispatched when no changes to the list was made and the results in the detail object seemed to be off-by-1.
function index (element, elementList) {
if (!(element instanceof Element) || !(elementList instanceof NodeList || elementList instanceof HTMLCollection || elementList instanceof Array)) {
throw new Error('You must provide an element and a list of elements.');
}
return Array.from(elementList).indexOf(element);
}
The index function is called few times across the code - firstly at dragstart
to get the initial listItem index and then at drop
. At drop it gets both element and the elementList, yet this time elementList has a placeholder sitting in it... So the listItem index will be off-by-one.
Or am I missing something and just completely missed the point?
Thanks!