title: Draggable+Sortable & Scrollable Divs
body: <p>I have a container with a list of draggable items and container with a list of sortable items. The draggables &amp; the sortable list is connected, allowing the user to drag clones of the draggables to the sorted list.</p>
  
  <p>The draggable items appear in a vertical list, however the sortable items appear in a horizontal list, achieved by floating them left. The container of the sortable items has its overflow set to auto, resulting in a horizontal scrollbar if the contents overflow. The two containers appear right next to each other, the draggables to the left &amp; the sortables to the right.</p>
  
  <p>The problem I'm experiencing is when the container of sortable items is scrolled to the right, dragging from the draggables' container immediately fires the sortables' events. It appears as if the contents of the sortables' container is moved behind the draggables' container.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr"&gt;
  &lt;head&gt;
      &lt;title&gt;Sortables in scrollable divs&lt;/title&gt;
      &lt;script type="text/javascript" language="JavaScript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" language="JavaScript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js"&gt;&lt;/script&gt;
      &lt;script type="text/javascript" language="javascript"&gt;
          $(function() {
              $("#sortable").sortable({
                  start: function(event, ui) {
                      if (ui.helper !== null) console.log("sortable \"" + ui.helper.text() + "\" drag start");
                  },
                  stop: function(event, ui) {
                      if (ui.helper !== null) console.log("sortable \"" + ui.helper.text() + "\" drag stopped");
                      if (ui.item !== null) console.log("sortable item \"" + ui.item.text() + "\" drag stopped");
                  }
              });
  
              $("#sortable").sortable("disable");
  
              $("#draggable li").draggable({
                  connectToSortable: '#sortable',
                  helper: 'clone',
                  revert: 'invalid',
                  cursor: "default",
                  cursorAt: { top: -5, left: -5 },
                  start: function(event, ui) {
                      if (ui.helper !== null) console.log("draggable \"" + ui.helper.text() + "\" drag start");
                  },
                  stop: function(event, ui) {
                      if (ui.helper !== null) console.log("draggable \"" + ui.helper.text() + "\" drag stopped");
                  }
              });
  
              $("#container2").mouseenter(function() {
                  console.log("enter sortable container");
                  $("#sortable").sortable("enable");
              }).mouseleave(function() {
                  console.log("leaving sortable container");
                  $("#sortable").sortable("disable");
              });
  
              $("#draggable, #sortable").disableSelection();
          });
      &lt;/script&gt;
      &lt;style type="text/css"&gt;
          html, body, p, td, th, li, input, select, option, textarea
          {
              font-family: Verdana, Arial, Helvetica, sans-serif;
              font-size: 11px;
              color:#343E41;
          }
  
          .wrapper
          {
              position: relative;
              width: 100%;
              height: 100%;
              overflow: hidden;
              height: expression(this.parentNode.offsetHeight + "px");
          }
  
          .scroll-wrapper
          {
              position: relative;
              width: 100%;
              height: 100%;
              overflow: auto;
              height: expression(this.parentNode.offsetHeight + "px");
          }
  
          #container1
          {
              float:left;
              width:200px;
              height:400px;
              overflow:auto;
              border:solid #000 1px;
              margin:5px;
          }
  
          #container2
          {
              float:left;
              width:600px;
              height:400px;
              overflow:auto;
              border:solid #000 1px;
              margin:5px;
          }
  
          ul#draggable
          {
              padding:0;
              margin:0;
              list-style-image:none;
              list-style-position:outside;
              list-style-type:none;
          }
  
          ul#draggable li
          {
              display:block;
              margin:5px;
              border:solid #000 1px;
              height:50px;
              width:150px;
          }
  
          ul#sortable
          {
              padding:0;
              margin:0;
              list-style-image:none;
              list-style-position:outside;
              list-style-type:none;
              height:380px;
              width:744px;
          }
  
          ul#sortable li
          {
              display:block;
              float:left;
              margin:5px;
              border:solid #000 1px;
              height:370px;
              width:50px;
              text-align:center;
          }
      &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;form id="form1" action=""&gt;
          &lt;div id="container1"&gt;
              &lt;ul id="draggable"&gt;
                  &lt;li&gt;1A&lt;/li&gt;
                  &lt;li&gt;2A&lt;/li&gt;
                  &lt;li&gt;3A&lt;/li&gt;
                  &lt;li&gt;4A&lt;/li&gt;
                  &lt;li&gt;5A&lt;/li&gt;
                  &lt;li&gt;6A&lt;/li&gt;
                  &lt;li&gt;7A&lt;/li&gt;
                  &lt;li&gt;8A&lt;/li&gt;
                  &lt;li&gt;9A&lt;/li&gt;
                  &lt;li&gt;10A&lt;/li&gt;
                  &lt;li&gt;11A&lt;/li&gt;
                  &lt;li&gt;12A&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
          &lt;div id="container2"&gt;
              &lt;ul id="sortable"&gt;
                  &lt;li class="ui-state-default"&gt;1&lt;/li&gt;
                  &lt;li class="ui-state-default"&gt;2&lt;/li&gt;
                  &lt;li class="ui-state-default"&gt;3&lt;/li&gt;
                  &lt;li class="ui-state-default"&gt;4&lt;/li&gt;
                  &lt;li class="ui-state-default"&gt;5&lt;/li&gt;
                  &lt;li class="ui-state-default"&gt;6&lt;/li&gt;
                  &lt;li class="ui-state-default"&gt;7&lt;/li&gt;
                  &lt;li class="ui-state-default"&gt;8&lt;/li&gt;
                  &lt;li class="ui-state-default"&gt;9&lt;/li&gt;
                  &lt;li class="ui-state-default"&gt;10&lt;/li&gt;
                  &lt;li class="ui-state-default"&gt;11&lt;/li&gt;
                  &lt;li class="ui-state-default"&gt;12&lt;/li&gt;
              &lt;/ul&gt;
          &lt;/div&gt;
      &lt;/form&gt;
  &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>How can I avoid the sortable events to fire until the item is dragged over the sortable container?</p>
  
  <p>Thanks in advance</p>