drag into different divs and containment

drag into different divs and containment

Hello,
I want to drag divs into two different divs ( drop1 / drop2 ). It works for one box as desired (drop1). But I want this for both divs (drop1 / drop2) and it should be possible that the drag-container can be moved between the two divs (drop1 / drop2). 

  1. var num1, cnt1 = 0;
  2. $(function() {
  3.   $('.drag').draggable({
  4.   revert: 'invalid',
  5.   containment: '#drop2, #drop1',
  6.   snap: '#drop2, #drop1',
  7.   stack: 'div',
  8.   opacity: 0.7,
  9.   start: function(e, ui) {
  10.     num1 = $(this).attr('rel');
  11.   },
  12.   stop: function(e, ui) {
  13.   }
  14. }).each(
  15.   function() {
  16.     var diffDrag1 = $('#start').offset().left + 9*cnt1;
  17.     var diffDrag2 = $('#start').offset().top  + 9*cnt1;
  18.     $(this).css({'left':diffDrag1,'top':diffDrag2});
  19.     cnt1++;
  20.   });
  21.   $('#drop1').droppable({
  22.     activeClass: 'active1',
  23.     hoverClass: 'hover1',
  24.     tolerance: 'touch',
  25.     drop: function(e, ui) {
  26.     }
  27.   });
  28. });
if the draggable and droppable function in loop, like:

  1. var num1, cnt1 = 0;
  2. $(function() {
  3.   $('.drag').draggable({
  4.   revert: 'invalid',
  5.   containment: '#drop2, #drop1',
  6.   snap: '#drop2, #drop1',
  7.   stack: 'div',
  8.   opacity: 0.7,
  9.   start: function(e, ui) {
  10.     num1 = $(this).attr('rel');
  11.   },
  12.   stop: function(e, ui) {
  13.   }
  14. }).each(
  15.   function() {
  16.     var diffDrag1 = $('#start').offset().left + 9*cnt1;
  17.     var diffDrag2 = $('#start').offset().top  + 9*cnt1;
  18.     $(this).css({'left':diffDrag1,'top':diffDrag2});
  19.     cnt1++;
  20.   });
  21.   $('#drop1').droppable({
  22.     activeClass: 'active1',
  23.     hoverClass: 'hover1',
  24.     tolerance: 'touch',
  25.     drop: function(e, ui) {
  26.     }
  27.   });
  28. });
then the drag-divs (drag1, drag2, drag3) snap into the left corner of the drop-divs. Why? And have anyone a hint for me..