0

Can anybody tell me how to get touch coordinates in hammerjs? Following code is giving error:

hammerEvent.on('pan', (ev) => {
  console.log('x, y: ', ev.clientX, ev.clientY);
}
5
  • try ev.deltaX, ev.deltaY
    – Haydar C.
    Commented Nov 16, 2020 at 11:47
  • @AhbapAldirmaz They are not touch coordinates. Commented Nov 16, 2020 at 11:49
  • Inside the ev object there is a PointerEvent named changedPointers. There are clientX and clientY values. ev.changedPointers[0].clientX, ev.changedPointers[0].clientY, Look at this.
    – Haydar C.
    Commented Nov 20, 2020 at 2:43
  • Yes but only one touch coordinate is coming. You touch screen with four fingers than also length of changedPointers is 1 only. I think its a bug. Commented Nov 20, 2020 at 9:55
  • Any luck for this? ev.changedPointers[0].clientX, ev.changedPointers[0].clientY, values of these to properties jump sometimes. Like 1 instance it was 325...326...327...410 Which property gives the exact cords?
    – Jivan
    Commented Jun 18, 2021 at 11:00

0

Browse other questions tagged or ask your own question.