Hi,
I have a few list items and id like a slide effect between the two items that are being swapped around.
This is what I have so far. This animation works the first time around, however after that, the list items that were originally moved have a 'top' value of 0 and I'm not sure why. I think this is the reason but not sure. I've also tried setting the position back to normal once the animation completes but that didn't work either.
listItemPushed
is the <li>
on the top, listItem
is the <li>
underneath it
listItemPushed.css('position', 'relative');
listItem.css('position', 'relative');
var top1 = listItemPushed.position().top;
var top2 = listItem.position().top;
listItemPushed.animate({ top: (top2-top1) }, 300);
listItem.animate({ top: (top1 - top2) }, 300, 'linear', function() {
listItemPushed.before(listItem);
});