title: addEventListener touchstart and touchend not working
body: <p>Script is functioning as expected on a PC, but nothing happens in the mobile version.</p>
  <p>How do I get it working so that a swipe left or right moves the div accordinly?</p>
  <p>More stuff here so I can actually submit all the code.</p>
  <pre><code>document.addEventListener(&quot;touchstart&quot;, touchStart, false);
  document.addEventListener(&quot;touchend&quot;, touchEnd, false);
  document.addEventListener(&quot;mousedown&quot;, touchStart, false);
  document.addEventListener(&quot;mouseup&quot;, touchEnd, false);
  var xDown = null;
  var yDown = null;
  function touchStart(event)
  {
      xDown = event.clientX;
      yDown = event.clientY;
  } 
  function touchEnd(event)
  {
      var currentPlayerPosition = parseInt(window.getComputedStyle(playerModel, null).getPropertyValue('left'));
      if ( ! xDown || ! yDown ) {
          return;
      }
      var xUp = event.clientX;                                    
      var yUp = event.clientY;
      var xDiff = xDown - xUp;
      var yDiff = yDown - yUp;                                                                     
      if ( Math.abs( xDiff ) &gt; Math.abs( yDiff ) ) {
          if ( xDiff &gt; 0 ) {
              if(currentPlayerPosition &lt;= &quot;25&quot;)
              {
                  return;
              }                document.getElementById(&quot;playerModel&quot;).style.left = currentPlayerPosition - 25 + &quot;px&quot;;
          } else {
              if(currentPlayerPosition &gt;= &quot;230&quot;)
              {
                  return;
              }               document.getElementById(&quot;playerModel&quot;).style.left = currentPlayerPosition + 25 + &quot;px&quot;;
          }                       
      } else {
          if ( yDiff &gt; 0 ) {
          } else { 
          }                                                                 
      }
      xDown = null;
      yDown = null;       
  }
  </code></pre>