title: Draggable elements via touch on iOS
body: <p>I need to make an item draggable via the mouse and via touch on iOS devices, without installing any new libraries such as jquery-ui.</p>
  
  <p>The answer found here <a href="https://stackoverflow.com/a/16448981/8799440">https://stackoverflow.com/a/16448981/8799440</a>
  worked really well for the mouse events.</p>
  
  <p>Below is what is retrieved from that answer:</p>
  
  <pre class="lang-js prettyprint-override"><code>function handle_mousedown(e){
      window.my_dragging = {};
      my_dragging.pageX0 = e.pageX;
      my_dragging.pageY0 = e.pageY;
      my_dragging.elem = this;
      my_dragging.offset0 = $(this).offset();
      function handle_dragging(e){
          var left = my_dragging.offset0.left + (e.pageX - my_dragging.pageX0);
          var top = my_dragging.offset0.top + (e.pageY - my_dragging.pageY0);
          $(my_dragging.elem)
          .offset({top: top, left: left});
      }
      function handle_mouseup(e){
          $('body')
          .off('mousemove', handle_dragging)
          .off('mouseup', handle_mouseup);
      }
      $('body')
      .on('mouseup', handle_mouseup)
      .on('mousemove', handle_dragging);
  }
  
  $('#id').mousedown(handle_mousedown);
  </code></pre>
  
  <p>I've tried reusing this code, with all the touch counterparts for the mouse events such as <code>touchstart</code> instead of <code>mousedown</code></p>
  
  <p>But that as expected doesn't seem to work, I suspect this is because the touch API is completely different from the mouse API</p>
  
  <p>Is there a work around to make this work?</p>
  
  <p>Thank you!</p>