|
58 | 58 | <td>
|
59 | 59 | <div class="reset" id="reset"><div class="flex=item" id="resettext">1: START</div></div>
|
60 | 60 | <div class="pointer" id="target">
|
61 |
| - <div class="flex-item"><br>2: CLICK<br> |
62 |
| - <br><span class='s3'>MOUSE</span><br>middle or<br>context<br> |
63 |
| - <br><span class='s3'>TOUCH | PEN</span><br>tap + drag a bit<br>tap again</div> |
| 61 | + <div class="flex-item"><br>2: CLICK<br><br>context click<br>(if you can)<br><br>otherwise<br><br>keep stabbing<br>and moving</div> |
64 | 62 | </div>
|
65 | 63 | <div class="reset"><div class="flex=item">3: FINISH</div></div>
|
66 | 64 | </td>
|
|
126 | 124 | altitudeAngle: "number",
|
127 | 125 | azimuthAngle: "number",
|
128 | 126 | }
|
129 |
| -// events we want to catch data on |
| 127 | +// events |
130 | 128 | let oDataEvents = {
|
131 | 129 | 'pointer': ['down','enter','leave','move','over','out','up'],
|
132 | 130 | 'touch': ['cancel','end','move','start'],
|
133 | 131 | }
|
| 132 | +let oNonDataEvents = { |
| 133 | + 'mouse': ['down','enter','leave','move','out','over','up'], |
| 134 | + 'pointer': ['cancel'], |
| 135 | + //'touch': ['cancel'], |
| 136 | +} |
134 | 137 |
|
135 | 138 | function finish() {
|
136 | 139 | // check all events have been recorded
|
|
172 | 175 |
|
173 | 176 | try {
|
174 | 177 | let touch = event.touches[0]
|
| 178 | + // touchcancel + touchend don't have touch data |
| 179 | + if (undefined == touch) { |
| 180 | + touch = event.changedTouches[0] |
| 181 | + } |
175 | 182 | aList.forEach(function(k){
|
176 | 183 | let value
|
177 | 184 | try {
|
|
183 | 190 | }
|
184 | 191 | oTemp[input][type][k] = value
|
185 | 192 | } catch(e) {
|
186 |
| - // touchcancel and touchend don't have values except for force |
187 |
| - // so don't record them if we catch a TypeError |
188 |
| - // this means we can now properly compare valid matches in screen/client X/Y |
189 |
| - if (e.name == 'TypeError' && k !== 'force') { |
190 |
| - // record nothing |
191 |
| - } else { |
192 |
| - oTemp[input][type][k] = e.name |
193 |
| - } |
| 193 | + oTemp[input][type][k] = e.name |
194 | 194 | }
|
195 | 195 | })
|
196 | 196 |
|
|
205 | 205 | // if all tests are the same value just display one value
|
206 | 206 | let aSet = new Set(), aArray = []
|
207 | 207 | for (const p of Object.keys(oTemp[input]).sort()) { // sort so array is in order when needed
|
208 |
| - if (undefined !== oTemp[input][p][k]) { |
209 |
| - let x = oTemp[input][p][k] |
210 |
| - // force is variable |
211 |
| - if ('force' == k) {if (!aStable.includes(x)) {x = 'float'}} |
212 |
| - aSet.add(x) |
213 |
| - aArray.push(x) |
214 |
| - } |
| 208 | + let x = oTemp[input][p][k] |
| 209 | + // force is variable |
| 210 | + if ('force' == k) {if ('number' == typeof x && !aStable.includes(x)) {x = 'float'}} |
| 211 | + aSet.add(x) |
| 212 | + aArray.push(x) |
215 | 213 | }
|
216 | 214 | let fp = aArray
|
217 | 215 | if (1 == aSet.size) {aArray = Array.from(aSet); fp = aArray[0]}
|
|
299 | 297 | let x = oTemp[input][p][k]
|
300 | 298 | // active pen pressure is variable between 0-1
|
301 | 299 | if ('pressure' == k || 'mozPressure' == k) {
|
302 |
| - if (!aStable.includes(x)) {x = 'float'} |
| 300 | + if ('number' == typeof x && !aStable.includes(x)) {x = 'float'} |
303 | 301 | }
|
304 | 302 | aSet.add(x)
|
305 | 303 | aArray.push(x)
|
|
346 | 344 |
|
347 | 345 | function start() {
|
348 | 346 | let target = dom.target
|
349 |
| - // just record the event happening |
350 |
| - let oEvents = { |
351 |
| - 'mouse': ['down','enter','leave','move','out','over','up'], |
352 |
| - 'pointer': ['cancel'] |
353 |
| - } |
354 |
| - for (const k of Object.keys(oEvents)) { |
355 |
| - let list = oEvents[k] |
| 347 | + // record the event happening |
| 348 | + for (const k of Object.keys(oNonDataEvents)) { |
| 349 | + let list = oNonDataEvents[k] |
356 | 350 | list.forEach(function(type){
|
357 | 351 | target.addEventListener(k + type, (event) => {addEvent(k + type)})
|
358 | 352 | })
|
359 | 353 | }
|
| 354 | + // record data on these events |
360 | 355 | for (const k of Object.keys(oDataEvents)) {
|
361 | 356 | let list = oDataEvents[k]
|
362 | 357 | dom[k +'events'].innerHTML = ' [' + list.join('|') +'] '
|
|
0 commit comments