title: using jquery sortable with css transform/transition
body: <p>I have a page that uses transform to slide the content when navigating.  Some of the content has jQuery sortable table rows.  At first, the sorting works as expected.  But after clicking a nav item (thus applying a transform and sliding to the desired content), sorting does not act as expected.  Instead, when you click on the row to be dragged, it drops below the cursor making it hard to sort.  See the CodePen below as an example.  Try dragging a row before clicking on the nav, then see the difference after clicking the nav.</p>
  
  <p>Is there a way around this (I have no idea where to start)?  Or do I need to find a different way sliding my content?</p>
  
  <p><a href="https://codepen.io/thespareroomstudio/pres/XjrEyg" rel="nofollow">https://codepen.io/thespareroomstudio/pres/XjrEyg</a></p>
  
  <pre><code>&lt;nav&gt;
    &lt;ul&gt;
      &lt;li id='goto_slide-1' class='slideNavItem'&gt;Home&lt;/li&gt;
      &lt;li id='goto_slide-2' class='slideNavItem'&gt;Not Home&lt;/li&gt;
      &lt;li id='goto_slide-3' class='slideNavItem'&gt;Far from home&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/nav&gt;
  &lt;main&gt;
    &lt;div id='slide-1' class='slide active'&gt;
      &lt;table&gt;
        &lt;caption&gt;This is a table at home&lt;/captin&gt;
          &lt;thead&gt;
            &lt;tr&gt;
              &lt;td&gt;Col 1&lt;/td&gt;
              &lt;td&gt;Col 2&lt;/td&gt;
              &lt;td&gt;Col 3&lt;/td&gt;
              &lt;td&gt;Col 4&lt;/td&gt;
              &lt;td&gt;Col 5&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;5&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;5&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;5&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;5&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;5&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;5&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
    &lt;/div&gt;
    &lt;div id='slide-2' class='slide inactive'&gt;
      &lt;table&gt;
        &lt;caption&gt;This is a table not at home&lt;/captin&gt;
          &lt;thead&gt;
            &lt;tr&gt;
              &lt;td&gt;Col 1&lt;/td&gt;
              &lt;td&gt;Col 2&lt;/td&gt;
              &lt;td&gt;Col 3&lt;/td&gt;
              &lt;td&gt;Col 4&lt;/td&gt;
              &lt;td&gt;Col 5&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;5&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;5&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;5&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;5&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;5&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;5&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
    &lt;/div&gt;
    &lt;div id='slide-3' class='slide inactive'&gt;
      &lt;table&gt;
        &lt;caption&gt;This is a table far from home&lt;/captin&gt;
          &lt;thead&gt;
            &lt;tr&gt;
              &lt;td&gt;Col 1&lt;/td&gt;
              &lt;td&gt;Col 2&lt;/td&gt;
              &lt;td&gt;Col 3&lt;/td&gt;
              &lt;td&gt;Col 4&lt;/td&gt;
              &lt;td&gt;Col 5&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/thead&gt;
          &lt;tbody&gt;
            &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;5&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;5&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;5&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;5&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;5&lt;/td&gt;
            &lt;/tr&gt;
            &lt;tr&gt;
              &lt;td&gt;1&lt;/td&gt;
              &lt;td&gt;2&lt;/td&gt;
              &lt;td&gt;3&lt;/td&gt;
              &lt;td&gt;4&lt;/td&gt;
              &lt;td&gt;5&lt;/td&gt;
            &lt;/tr&gt;
          &lt;/tbody&gt;
      &lt;/table&gt;
    &lt;/div&gt;
  </code></pre>
  
  <h2>    </h2>
  
  <pre><code>body {
    overflow: hidden;
  }
  
  nav ul li {
    display: inline-block;
    margin-left: 1em;
    cursor: pointer;
  }
  
  table {
    border-collapse:  collapse;
    border:  1px solid #000;
    margin-bottom: 1em;
  }
  
  main {
    display: flex;
    width: 303%;
  }
  
  .slide {
    width: 100%;
  
    margin: 1em;
  }
  
  table tr:nth-child(even) {
    background-color:  lightgrey;
  }
  
  table td {
    border: 1px solid lightgray;
  }
  
  #slide-1 table {
    width: 100%;
  }
  
  #slide-1 table caption {
    background-color: lightblue;
    border: 1px solid #000;
  }
  
  #slide-2 table {
    width: 100%;
  }
  
  #slide-2 table caption {
    background-color: lightgreen;
    border: 1px solid #000;
  }
  
  #slide-3 table {
    width: 100%;
  }
  
  #slide-3 table caption {
    background-color: lightyellow;
    border: 1px solid #000;
  </code></pre>
  
  <h2>    }</h2>
  
  <pre><code>$("tbody").sortable({
    items: "&gt; tr"
  });
  
  $(document).on("click", ".slideNavItem", function() {
    var navID = $(this).attr('id');
    console.log(navID);
  
    var slideTo = $('#' + navID.split("_")[1]);
    console.log(slideTo);
    var inactiveElems = $("main").find(".slide.inactive").toggleClass("inactive");
    var curActiveElem = $("main").find(".slide.active");
    var wrapper = slideTo.closest("main");
    console.log(wrapper);
    var button = $(this);
    var wrapperInlineStyles = wrapper.attr('styles');
    if (wrapperInlineStyles === undefined) {
      wrapperInlineStyles = ""
    }
  
    var elemPos = slideTo.offset().left;
    console.log(elemPos);
    var moveTo = (wrapper.offset().left) - (elemPos);
    console.log(moveTo);
  
    wrapper.css({
      "transform": "translate(" + moveTo + "px, 0)",
      "transition": "1s ease-in-out"
    });
    wrapper.one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend',
      function(e) {
  
        $("main").find(".slide.active").removeClass("active") // remove active class from old position
        slideTo.addClass("active"); // add active classs to new position  
        $("main").find(".slide").not(".active").addClass("inactive"); // now add hide (add inactive class to)the other elemens 
        wrapper.css({
          "transition": "none"
        });
      });
  });
  </code></pre>