Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akhileshdarjee/f243d6477f3c6ab68d71332ed8aad4d3 to your computer and use it in GitHub Desktop.
Save akhileshdarjee/f243d6477f3c6ab68d71332ed8aad4d3 to your computer and use it in GitHub Desktop.
Always keep cursor horizontally and vertically center of the dragging object
$('body').find('.draggable').draggable({
stack: ".draggable",
helper: 'clone',
start: function(event, ui) {
$(this).draggable('instance').offset.click = {
left: Math.floor(ui.helper.width() / 2),
top: Math.floor(ui.helper.height() / 2)
};
ui.helper.css('cursor', 'move');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment