Draggable jQueryUI Margins Bug and Fix
Bug: Doesn't account for margins when dragging.
Fix: http://pastebin.com/pastebin.php?diff=m711babbe or see below
$.ui.plugin.add("draggable", "grid", {
drag: function(e, ui) {
var o = ui.options;
var t = $(ui.helper);
var newLeft = -parseInt(t.css('marginLeft')) +
ui.instance.originalPosition.left + Math.round((e.pageX -
ui.instance._pageX) / o.grid[0]) * o.grid[0];
var newTop = -parseInt(t.css('marginTop')) +
ui.instance.originalPosition.top + Math.round((e.pageY -
ui.instance._pageY) / o.grid[1]) * o.grid[1];
ui.instance.position.left = newLeft;
ui.instance.position.top = newTop;
}
});