Created
October 9, 2018 07:19
-
-
Save musaid/93e44a939cb1cc3dda8a9f0274f37b49 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
$('#sortable').sortable({ | |
start: function(event, ui) { | |
var start_pos = ui.item.index(); | |
ui.item.data('start_pos', start_pos); | |
}, | |
change: function(event, ui) { | |
var start_pos = ui.item.data('start_pos'); | |
var index = ui.placeholder.index(); | |
if (start_pos < index) { | |
$('#sortable li:nth-child(' + index + ')').addClass('highlights'); | |
} else { | |
$('#sortable li:eq(' + (index + 1) + ')').addClass('highlights'); | |
} | |
}, | |
update: function(event, ui) { | |
$('#sortable li').removeClass('highlights'); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment