event.js 499 B

123456789101112131415161718
  1. /**
  2. * 获得触发事件的坐标
  3. */
  4. export function getEventPos(e) {
  5. var canvas = e.canvas, touches = e.touches, offsetX = e.offsetX, offsetY = e.offsetY;
  6. if (canvas) {
  7. var x = canvas.x, y = canvas.y;
  8. return [x, y];
  9. }
  10. if (touches) {
  11. var _a = touches[0], clientX = _a.clientX, clientY = _a.clientY;
  12. return [clientX, clientY];
  13. }
  14. if (offsetX && offsetY)
  15. return [offsetX, offsetY];
  16. return [0, 0];
  17. }
  18. //# sourceMappingURL=event.js.map