Game Development Reference
In-Depth Information
touchend
Similar to a mouse up event, a
touchend
event is fired when any of the registered
touch events leave the input touch device.
document.body.addEventListener("touchend",
doOnTouchEnd);
function doOnTouchEnd(event) {
event.preventDefault();
// ...
}
Just like a
touchstart
event, the object passed into the registered
callback
function is an instance of the
TouchEvent
class, which contains the same three
TouchList
attributes. The context of the
touches
and
targetTouches
attributes
are the exact same as their version found in
touchstart
. However, the
changedTouches
touch list has a slightly different meaning in this event.
Although the
TouchList
object inside a
touchend
event is the exact same as the
one in
touchstart
, the list of touch objects contained here represents touches that
have left the touch input device.
touchmove
The
touchmove
event, analogous to a
drag
event, is fired whenever at least one of
the registered touch objects changes position without triggering a
touchend
event.
As we'll soon see each touch object is uniquely tracked so that it is possible to de-
termine if any of the registered touch objects have moved and which ones have ac-
tually displaced.
document.body.addEventListener("touchmove",
doOnTouchMove);
function doOnTouchMove(event) {