Game Development Reference
In-Depth Information
event.preventDefault();
// ...
}
Again, just like a touchend 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 . The touch objects in
the changedTouches list in the touchmove event represent previously registered
touches that have moved about the input device.
One important thing about the touchmove event is that it can be associated with
a drag event. If you notice, the default behavior for a drag event is to scroll the
page in the direction of the scroll. In some applications involving dragging across
the screen with a finger, this behavior may not be desired. For this reason, the
event.preventDefault() method is called, which produces the effect of alert-
ing the browser that no scrolling is desired. If, however, the intention is to scroll the
screen with a touchmove event, provided that the element being touched supports
such behavior, this can be accomplished by omitting the call to the prevent default
function.
The touch object
Now, you may have noticed that each TouchList object holds instances of a very
specific object which is an instance of the Touch class. This is important because
the input device needs to keep track of individual touches. Otherwise, the list of
changedTouches would not be accurate thus limiting what we can accomplish with
the API.
The way that each touch can be uniquely identified is by having the input device as-
sign a unique ID to each event it captures. This ID remains the same for the same
touch object until that object is released (in other words, when that particular touch
leaves the input device).
Lets take a look at all the other properties of the Touch class and see what other
important information is contained therein.
Search WWH ::




Custom Search