this question has been asked several times before, but I haven't seen any answers. I'd thought I would give it a shot.
I'm using the jQuery UI draggable (and droppable) functions on multiple items. When the items are dragged, they never align to the same grid line, so this makes it pointless for lining up items.
I tried laying out a thousand <div class="grid-cell">
but this causes some noticeable performance issues when replicated over a couple droppable zones and css animations.
Here is an example of items not lining up to the same grid: http://jsfiddle.net/K3zzY/
Here are some similar questions: jQuery Draggable Custom Snap to Grid jQuery UI Draggable, Snapping to a Grid https://stackoverflow.com/questions/17353256/jquery-ui-draggable-to-fixed-grid
Thanks for any suggestions.
I also tried to manipulate the draggable's position on:drag, but it doesn't seem to work as in the element never seems to be repositioned.
My Approach Using a code suggestion from here: Draggable square/rectangle that snaps to grid in JQuery/Javascript
I have my code as:
drag:function(e, ui){
if(snapToGrid === true){
ui.position.left = Math.floor((e.pageX - f._wrapper.offset().left) / snapToGridSize) * snapToGridSize,
ui.position.top = Math.floor((e.pageY - f._wrapper.offset().top) / snapToGridSize) * snapToGridSize
}
}