HTML5 Games by Jacob Seidelin
Author:Jacob Seidelin
Language: eng
Format: epub
ISBN: 9781118855454
Publisher: Wiley
Published: 2014-02-04T14:28:36+00:00
This short example simply prints the x and y coordinates in the corresponding input elements when you move your finger across the screen. Note that because it accesses only the first element of the touches list, this event works only with the first finger that touches the screen. As you see in the next section, however, working with multiple touch objects is also easy.
Multitouch
The touches array lists all active touches, and if more than one finger is touching the screen, you don't know which one is the relevant touch object. The event object provides two additional lists that you can use to get around this problem: targetTouches and changedTouches. The targetTouches list contains only the touch objects that are active on the target element. So, if a touchstart event fires on, say, a div element, the targetTouches list lists only the touch objects on that specific div, whereas the touches list might contain other, unrelated touch objects. The changedTouches list adds a further restriction and lists only the touch objects involved in that specific event. So, if you have two fingers on the div and move only one, the targetTouches list in the touchmove event contains both touch objects, but the changedTouches gives you only the one that moved.
The first example is a multitouch-enabled feature that lets you drag multiple elements around at the same time. Listing 8-3 shows the code, which you also can find in the file 03-multidrag.html. This file also includes a bit of CSS to style the two draggable elements.
Listing 8-3 Multitouch drag
<div id="dragme1"></div>
<div id="dragme2"></div>
<script>
var el1 = document.getElementById("dragme1"),
el2 = document.getElementById("dragme2");
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Deep Learning with Python by François Chollet(15283)
The Mikado Method by Ola Ellnestam Daniel Brolund(12553)
Hello! Python by Anthony Briggs(12416)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(11740)
Dependency Injection in .NET by Mark Seemann(11536)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(10532)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(10352)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(10038)
Grails in Action by Glen Smith Peter Ledbrook(9677)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(9310)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(9160)
Hit Refresh by Satya Nadella(9040)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(8498)
The Kubernetes Operator Framework Book by Michael Dame(8479)
Exploring Deepfakes by Bryan Lyon and Matt Tora(8300)
Robo-Advisor with Python by Aki Ranin(8256)
Practical Computer Architecture with Python and ARM by Alan Clements(8227)
Implementing Enterprise Observability for Success by Manisha Agrawal and Karun Krishnannair(8198)
Building Low Latency Applications with C++ by Sourav Ghosh(8103)