Skip to content

Instantly share code, notes, and snippets.

@Gazzell
Created April 17, 2020 12:05
Show Gist options
  • Save Gazzell/62458f1dd791738ade0c5634ab0bdf37 to your computer and use it in GitHub Desktop.
Save Gazzell/62458f1dd791738ade0c5634ab0bdf37 to your computer and use it in GitHub Desktop.
function firePointerEvent(el, eventName, x,y){
const ev = new MouseEvent(eventName, {
clientX: x, clientY: y, bubbles: true, cancelable: true
});
el.dispatchEvent(ev);
}
var relativePosition = APP.getNodePositionAsOffset("cards.ticket1.emptyTicket.buttonAdd")
var canvas = document.getElementsByTagName("canvas")[0];
var rect = canvas.getBoundingClientRect();
firePointerEvent(canvas, "pointerdown", rect.x + relativePosition.x, rect.y + relativePosition.y);
firePointerEvent(canvas, "pointerup", rect.x + relativePosition.x, rect.y + relativePosition.y);
relativePosition = APP.getNodePositionAsOffset("cards.ticket2.emptyTicket.buttonAdd")
firePointerEvent(canvas, "click", rect.x + relativePosition.x, rect.y + relativePosition.y);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment