kornelski / slip

Slip.js — UI library for manipulating lists via swipe and drag gestures
BSD 2-Clause "Simplified" License
2.44k stars 213 forks source link

Fix dragging first or last element of list where spliceIndex is same as originalIndex #69

Closed carter-thaxton closed 8 years ago

carter-thaxton commented 8 years ago

When dragging first or last element of the list, the logic to determine the new spliceIndex was not always working if spliceIndex ended up the same as originalIndex. This would result in no 'slip:reorder' event firing on mouseup/touchup.

This pull request fixes this by handling the edge cases of searching the list of otherNodes and not finding a node that satisifes the condition of "otherNode.pos > move.y" (or < move.y, when moving the other way).

This is a possible fix for issue #65.

kornelski commented 8 years ago

That's great. Thank you.