title: Detect left/right-swipe on touch-devices, but allow up/down-scrolling
body: <p>I need to detect and react to left/right-swipes, but want to give the user the ability to scroll on the same element, so as long as he moves his finger only left/right with a maximum up/down movement of X pixels, it should not scroll, but when he exceeds X, it should scroll.</p>
  
  <p>So what I did is:</p>
  
  <pre><code>var startX, startY, $this = $(this);
  function touchmove(event) {
          var touches = event.originalEvent.touches;
          if (touches &amp;&amp; touches.length) {
              var deltaX = touches[0].pageX - startX;
              var deltaY = touches[0].pageY - startY;
              if (Math.abs(deltaY) &gt; 50) {
                  $this.html('X: ' + deltaX + '&lt;br&gt; Y: ' + deltaY + '&lt;br&gt;TRUE');
                  $this.unbind('touchmove', touchmove);
                  return true;
              } else {
                  $this.html('X: ' + deltaX + '&lt;br&gt; Y: ' + deltaY);
                  event.preventDefault();
              }
          }
      }
  
      function touchstart(event) {
          var touches = event.originalEvent.touches;
          if (touches &amp;&amp; touches.length) {
              startX = touches[0].pageX;
              startY = touches[0].pageY;
              $this.bind('touchmove', touchmove);
          }
          //event.preventDefault();
      }
  </code></pre>
  
  <p>But I doesn't restore the ability to scroll in the "if" case... </p>
  
  <p>Thanks for any tips.</p>