Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Combining jQuery UI selectable and draggable
$(function () {
'use strict';
var selected = $([]), offset = {top: 0, left: 0};
$("#container").selectable();
$("#container div").draggable({
snap : true,
start: function () {
if (!$(this).is(".ui-selected")) {
$(".ui-selected").removeClass("ui-selected");
}
selected = $(".ui-selected").each(function () {
var element = $(this);
element.data("offset", element.offset());
});
offset = $(this).offset();
},
drag: function (event, ui) {
var draggedTop = ui.position.top - offset.top, draggedLeft = ui.position.left - offset.left;
selected.not(this).each(function () {
var element = $(this), off = element.data("offset");
element.css({top: off.top + draggedTop, left: off.left + draggedLeft});
});
}
});
});
@veteran1

i can't select//deselect another element by ctrl+right click

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment