Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable automatic sort and swap elements. #1072

Closed
jsgv opened this issue Mar 27, 2017 · 0 comments
Closed

Disable automatic sort and swap elements. #1072

jsgv opened this issue Mar 27, 2017 · 0 comments

Comments

@jsgv
Copy link

jsgv commented Mar 27, 2017

JS Bin: http://jsbin.com/zukifob/edit?js,console,output

I am trying to disable the sort functionality. I don't want the list to be automatically sorted nor for the elements to be slid up.

Instead of the elements sliding up as I drag the element I want to reposition, I want it to be swapped with whatever element is below, or the current index/location of the dragged element.

The onEnd event, only passes the same index for both the oldIndex and newIndex

onEnd: function(evt) {
    evt.oldIndex; // 1
    evt.newIndex; // 1
}

I can see the oldIndex in the onStart event. How can I see the new selected index while disabling the sort functionality.

gazugafan added a commit to gazugafan/Sortable that referenced this issue Jan 28, 2018
This is a rough implementation of a swapping feature. Setting the new "swap" option to true will cause a dragged item to be swapped with the item you drop it on (instead of inserted next to it). The item being hovered over (and potentially swapped with) will be highlighted by adding the class specified in the new "swapHighlightClass" option (defaults to "sortable-swap-highlight"). When swapping is enabled, the "end" event's "to" property will be set to the item being dropped on and swapped with.

It's a bit hackish, but it works as a solution to issues SortableJS#1211, SortableJS#1082, SortableJS#1072, SortableJS#891, SortableJS#869, and SortableJS#469. Maybe it can at least serve as a starting off point to adding this feature to master eventually? Thanks!
@jsgv jsgv closed this as completed May 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant