title: jQuery draggable + droppable: how to snap dropped element to dropped-on element
body: <p>I have my screen divided into two <code>DIV</code>s. In the left <code>DIV</code> I have a few 50x50 pixel <code>DIV</code>s, in the right <code>DIV</code> I have an empty grid made of 80x80 <code>LI</code>s. The <code>DIV</code>s on the left are draggable, and once dropped on a <code>LI</code>, they should snap to center of that <code>LI</code>.</p>
  
  <p>Sounds simple, right? I just don't know how to get this done. I tried by manipulating the dropped <code>DIV</code>'s <code>top</code> and <code>left</code> CSS properties to match those of the <code>LI</code> they're dropped into, but the <code>left</code> and <code>top</code> properties are relative to the left <code>DIV</code>.</p>
  
  <p>How can I best have the dropped element snap to the center of the element it's dropped into? That's gotta be simple, right?</p>
  
  <p><strong>Edit:</strong> I'm using jQuery UI 1.7.2 with jQuery 1.3.2.</p>
  
  <p><strong>Edit 2:</strong> For whoever else has this problem, this is how I fixed it:</p>
  
  <p>I used Keith's solution of removing the dragged element and placing it inside the dropped-on element in the <code>drop</code> callback of the droppable plugin:</p>
  
  <pre><code>function gallerySnap(droppedOn, droppedElement)
  {
      $(droppedOn).html('&lt;div class="drop_styles"&gt;'+$(droppedElement).html()+'&lt;/div&gt;' );
      $(droppedElement).remove();
  }
  </code></pre>
  
  <p>I don't the dropped element to be draggable again, but if you do, just bind draggable to it again.</p>
  
  <p>For me this method also solved the problem I had when positioning the dropped elements (which would be relative to the left <code>DIV</code>) and scrolling inside the second <code>DIV</code>. (Elements would remain fixed on page, now they scroll along).</p>
  
  <p>I did play with the snap options to make it look good while dragging, so thanks to karim79 for that suggestion.</p>
  
  <p>I probably won't win any Awesome Code prizes with this, so if you see room for improvement, please share!</p>