También necesitaba hacer lo mismo, y no quería utilizar la extensión de interfaz de eyecon.ro. Después de algunas investigaciones, encontré Combining Selectables And Draggables Using jQuery UI. Está muy bien dicho, pero para hacer que los fragmentos de código se ejecuten hay que profundizar en ello. Pude hacer que funcione. Lo cambié ligeramente, esta es mi manera de hacerlo. Necesita modificaciones para usar en el nivel de producción, pero espero que ayude.
// this creates the selected variable
// we are going to store the selected objects in here
var selected = $([]), offset = {top:0, left:0};
// initiate the selectable id to be recognized by UI
$("#selectable").selectable({
filter: 'div',
});
// declare draggable UI and what we are going to be doing on start
$("#selectable div").draggable({
start: function(ev, ui) {
selected = $(".ui-selected").each(function() {
var el = $(this);
el.data("offset", el.offset());
});
if(!$(this).hasClass("ui-selected")) $(this).addClass("ui-selected");
offset = $(this).offset();
},
drag: function(ev, ui) {
var dt = ui.position.top - offset.top, dl = ui.position.left - offset.left;
// take all the elements that are selected expect $("this"), which is the element being dragged and loop through each.
selected.not(this).each(function() {
// create the variable for we don't need to keep calling $("this")
// el = current element we are on
// off = what position was this element at when it was selected, before drag
var el = $(this), off = el.data("offset");
el.css({top: off.top + dt, left: off.left + dl});
});
}
});
Estilos CSS para ser capaz de ver lo que está sucediendo:
#selectable { width: 100%; height: 100%;}
#selectable div {
background: #ffc;
line-height: 25px;
height: 25px;
width: 200px;
border: 1px solid #fcc;
}
#selectable div.ui-selected {
background: #fcaf3e;
}
#selectable div.ui-selecting {
background: #8ae234;
}
Formato HTML:
<div id="selectable">
<div>item 1</div>
<div>item 2</div>
<div>item 3</div>
<div>item 4</div>
</div>
Código en http://stackoverflow.com/questions/34698117/elements-became-randomly-non-resizable-after-dragging queston también contiene una respuesta a esta pregunta Sin embargo, el código en las respuestas causa una pérdida aleatoria del tamaño en el arrastre – Andrus