3

As far as I can tell, the event triggered by ontouchmove in mobile Safari only contains information about on which element the touch began. For example, let's assume I put my finger down on the element .firstElement and then drag it across the page until it is over .secondElement. I've inspected all the properties of the event object, but I can only seem to find references the .firstElement.

Is there a way to detect with ontouchmove which element the user's finger is currently touching?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
maxedison
  • 17,243
  • 14
  • 67
  • 114

1 Answers1

11

This appears to be a duplicate of How to find out the actual event.target of touchmove javascript event?

According to that answer, there is no data in the event object that references the element that the finger is currently over. You can, however determine it with the following code:

var secondElement = document.elementFromPoint(event.clientX, event.clientY);
Community
  • 1
  • 1
Brian Nickel
  • 26,890
  • 5
  • 80
  • 110
  • 2
    Thanks, I actually just came across that solution myself! I'll award you the points though. And FWIW, I did search extensively on SO for an answer to it; I think SO's search engine could be improved... – maxedison Nov 14 '11 at 15:17
  • I had to do: var currentElement = document.elementFromPoint(e.touches[0].clientX, e.touches[0].clientY); – aharris88 May 30 '15 at 18:06