title: convert touch event to mouse events only works every second time
body: <p>I am using the following script, to convert touch events to mouse events. It works pretty fine, however between two touch events (for example with panning through data of a diagram) the second event is not triggered. Then the next event is triggered, the next not and so on.</p>
  
  <p>So this is my function to so found <a href="https://stackoverflow.com/questions/1517924/javascript-mapping-touch-events-to-mouse-events">here</a></p>
  
  <pre><code>function touchHandler(event)
  {
      var touches = event.changedTouches,
          first = touches[0],
          type = "";
      switch(event.type)
      {
          case "touchstart": type = "mousedown"; break;
          case "touchmove":  type = "mousemove"; break;        
          case "touchend":   type = "mouseup";   break;
          default:           return;
      }
  
      // initMouseEvent(type, canBubble, cancelable, view, clickCount, 
      //                screenX, screenY, clientX, clientY, ctrlKey, 
      //                altKey, shiftKey, metaKey, button, relatedTarget);
  
      var simulatedEvent = document.createEvent("MouseEvent");
      simulatedEvent.initMouseEvent(type, true, true, window, 1, 
                                    first.screenX, first.screenY, 
                                    first.clientX, first.clientY, false, 
                                    false, false, false, 0/*left*/, null);
  
      first.target.dispatchEvent(simulatedEvent);
      event.preventDefault();
  }
  
  function init() 
  {
      document.addEventListener("touchstart", touchHandler, true);
      document.addEventListener("touchmove", touchHandler, true);
      document.addEventListener("touchend", touchHandler, true);
      document.addEventListener("touchcancel", touchHandler, true);    
  }
  </code></pre>
  
  <p>Anyone knows why this behaviour is like that? </p>
  
  <p>UPDATE: I found out, that the 'first.target' is first 'div.dragcover' and in the second try it'is 'rect' then again 'div.dragcover' and so on. Anyone knows why this is so?</p>