UNPKG

@animech-public/playcanvas

Version:
2 lines (1 loc) 771 B
function t(t){let e=0,s=0,o=t.target;for(;!(o instanceof HTMLElement)&&o;)o=o.parentNode;for(;o;)e+=o.offsetLeft-o.scrollLeft,s+=o.offsetTop-o.scrollTop,o=o.offsetParent;return{x:t.pageX-e,y:t.pageY-s}}class e{constructor(e){this.id=void 0,this.x=void 0,this.y=void 0,this.target=void 0,this.touch=void 0;const s=t(e);this.id=e.identifier,this.x=s.x,this.y=s.y,this.target=e.target,this.touch=e}}class s{constructor(t,s){this.element=void 0,this.event=void 0,this.touches=[],this.changedTouches=[],this.element=s.target,this.event=s,this.touches=Array.from(s.touches).map((t=>new e(t))),this.changedTouches=Array.from(s.changedTouches).map((t=>new e(t)))}getTouchById(t,e){return e.find((e=>e.id===t))||null}}export{e as Touch,s as TouchEvent,t as getTouchTargetCoords};