function dispatchTouchEvent(x, y, type) {
  var element = window.document.elementFromPoint(x, y);
  var inputDeviceCapabilities =
    new InputDeviceCapabilities({firesTouchEvents: true});
  var touch = new Touch({
    identifier: 0,
    target: element,
    clientX: x,
    clientY: y,
    pageX: x + window.document.scrollingElement.scrollLeft,
    pageY: y + window.document.scrollingElement.scrollTop,
    force: 1,
    radiusX: 1,
    radiusY: 1,
    screenX: x + window.screenX,
    screenY: y + window.screenY,
  });
  var event = new TouchEvent(type, {
    touches: [touch],
    targetTouches: [touch],
    changedTouches: [touch],
    ctrlKey: false,
    shiftKey: false,
    altKey: false,
    metaKey: false,
    view: window,
    bubbles: true,
    cancelable: false,
    composed: true,
    sourceCapabilities: inputDeviceCapabilities,
  });
  element.dispatchEvent(event);
}
/**
 * Dispatches a fake touch event with a single touch point.
 *
 * @param {number} x X-coordinate of the touch point relative to viewport
 *     in CSS pixels.
 * @param {number} y Y-coordinate of the touch point relative to viewport
 *     in CSS pixels.
 * @param {string} type Touch event type, e.g. touchstart.
 */
Dispatches a fake touch event with a single touch point.
@param {number} x X-coordinate of the touch point relative to viewport
in CSS pixels.
@param {number} y Y-coordinate of the touch point relative to viewport
in CSS pixels.
@param {string} type Touch event type, e.g. touchstart.
Dispatches a fake touch event with a single touch point . @param { number } x X - coordinate of the touch point relative to viewport in CSS pixels . @param { number } y Y - coordinate of the touch point relative to viewport in CSS pixels . @param { string } type Touch event type e . g . touchstart .
function dispatchTouchEvent(x, y, type) {
  var element = window.document.elementFromPoint(x, y);
  var inputDeviceCapabilities =
    new InputDeviceCapabilities({firesTouchEvents: true});
  var touch = new Touch({
    identifier: 0,
    target: element,
    clientX: x,
    clientY: y,
    pageX: x + window.document.scrollingElement.scrollLeft,
    pageY: y + window.document.scrollingElement.scrollTop,
    force: 1,
    radiusX: 1,
    radiusY: 1,
    screenX: x + window.screenX,
    screenY: y + window.screenY,
  });
  var event = new TouchEvent(type, {
    touches: [touch],
    targetTouches: [touch],
    changedTouches: [touch],
    ctrlKey: false,
    shiftKey: false,
    altKey: false,
    metaKey: false,
    view: window,
    bubbles: true,
    cancelable: false,
    composed: true,
    sourceCapabilities: inputDeviceCapabilities,
  });
  element.dispatchEvent(event);
}
function dispatchTouchEvent ( x , y , type ) { var element = window . document . elementFromPoint ( x , y ) ; var inputDeviceCapabilities = new InputDeviceCapabilities ( { firesTouchEvents : true } ) ; var touch = new Touch ( { identifier : 0 , target : element , clientX : x , clientY : y , pageX : x + window . document . scrollingElement . scrollLeft , pageY : y + window . document . scrollingElement . scrollTop , force : 1 , radiusX : 1 , radiusY : 1 , screenX : x + window . screenX , screenY : y + window . screenY , } ) ; var event = new TouchEvent ( type , { touches : [ touch ] , targetTouches : [ touch ] , changedTouches : [ touch ] , ctrlKey : false , shiftKey : false , altKey : false , metaKey : false , view : window , bubbles : true , cancelable : false , composed : true , sourceCapabilities : inputDeviceCapabilities , } ) ; element . dispatchEvent ( event ) ; }
Dispatches a fake touch event with a single touch point.
Dispatches a fake touch event with a single touch point .