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/580a452872fb28b439e6085353f0e2b8 to your computer and use it in GitHub Desktop.
Save akhileshdarjee/580a452872fb28b439e6085353f0e2b8 to your computer and use it in GitHub Desktop.
Set width and height while dragging object in jquery
$('body').find('.draggable').draggable({
revert: true,
revertDuration: 0,
stack: ".draggable",
helper: 'clone',
start: function(event, ui) {
$(ui.helper).removeAttr('width');
$(ui.helper).removeAttr('height');
var ele_width = $('body').find('.square').width();
var ele_height = $('body').find('.square').height();
$(ui.helper).width(ele_width).height(ele_height);
// you can also use static values
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment