Note that there are some explanatory texts on larger screens.

plurals
  1. POFind element finger is on during a touchend event
    primarykey
    data
    text
    <p>I need to discover which html element was under the finger when the touchend event is called. The code I am using;</p> <pre><code>$('.wsSquare').on("mouseup touchend",function(event){ event.preventDefault(); event.stopPropagation(); console.log($(event.target).data()); }); </code></pre> <p>Using the mouse on a (non-touch) device, this code correctly logs the data associated with the element under the mouse at the time of the mouseup event.</p> <p>However on a touch device (ipad safari), event.target is the element that was under the finger during the touchstart event and logs the data of the element under the touchstart event</p> <p>I've also examined the behavior of the touchmove event, this also has the same behaviour (the event.target is touchstart element). It seems that the target for all the touch events is the element touched at the beginning of the gesture.</p> <p>I need to access the element under the finger when the touchend event is called. My gesture potentially traverses many elements.</p> <h3>Edit</h3> <p>Further research dug up this from <a href="http://www.w3.org/TR/2011/WD-touch-events-20110505/#the-touchend-event" rel="noreferrer">the specification</a>.</p> <blockquote> <p>5.5 The touchend event</p> <p>A user agent must dispatch this event type to indicate when the user removes a touch point from the touch surface, also including cases where the touch point physically leaves the touch surface, such as being dragged off of the screen.</p> <p><strong>The target of this event must be the same Element on which the touch point started when it was first placed on the surface, even if the touch point has since moved outside the interactive area of the target element</strong>.</p> <p>The touch point or points that were removed must be included in the changedTouches attribute of the TouchEvent, and must not be included in the touches and targetTouches attributes.</p> </blockquote> <p>So the observed behavior is correct, how can I change this behavior?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload