title: Detect swipe direction without scrolling
body: <p>How can I detect the swipe direction without actually scrolling?  Here's what I'm doing:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>function preventDefault(e) {
    e = e || window.event;
    if (e.preventDefault)
        e.preventDefault();
    e.returnValue = false;  
  }
  
  window.ontouchmove  = preventDefault;
  
  window.addEventListener('touchmove', function(e) {
    if (e.deltaY &lt; 0) {
      console.log('scrolling up');
      document.getElementById('status').innerHTML = 'scrolling up';
    }
    if (e.deltaY &gt; 0) {
      console.log('scrolling down');
      document.getElementById('status').innerHTML = 'scrolling down';
    }
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div style='height: 2000px; border: 5px solid gray; touch-action: none;'&gt;
   &lt;p id='status'&gt;&lt;/p&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>What I observe is that although the screen does not scroll, none of the event listener code executes.  This is because there is no 'deltaY' property in the event.  I used the <a href="https://stackoverflow.com/a/34147719/2233706">equivalent code</a> on desktop with the 'wheel' event to detect the scroll direction without scrolling.</p>