Jquery Draggable - center cursorAt Vertically
I also wanted to center my draggable objects after I pick them up. My solution:
$(".dragme").draggable({
start: function(event, ui) {
$(this).draggable("option", "cursorAt", {
left: Math.floor(this.clientWidth / 2),
top: Math.floor(this.clientHeight / 2)
});
}
});
Worked around the initial problem, see the comment to my initial post.
EDIT:
Tolerance option "pointer": The mouse pointer overlaps the other item.
$(".sortable").sortable({
containment: "parent",
tolerance: "pointer"
});
This works fine if draggable have helper object. Just put it in start method of draggable as below code.
start: function(event, ui) {
$(this).draggable("option", "cursorAt", {
left: Math.floor(ui.helper.width() / 2),
top: Math.floor(ui.helper.height() / 2)
});
}