I’m trying to create a draggable div (constrained to the x axis) using JQuery that will reset to it’s original position when dragged. This is what I have so far but the animate function won’t work, I’ve tried replacing ui.draggable with ui.animate with no luck.
Here’s what I have written, I’d appreciate whatever help you can give!
$( '.selectedResult' ).draggable({
start: function(event, ui){
startPosition = ui.position.left;
},
stop: function(event, ui){
var move = startPosition - ui.position.left;
if(move > 0){
move = '+=' + move;
}else{
move = -move;
move = '-=' + move;
}
$(ui.draggable).animate({'left': move}, 'slow');
},
axis: 'x'
});
All is ok except
$(ui.draggable).animate({'left': move}, 'slow');. Replace it with