Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | 14x 14x 63x 63x 63x 58x 63x 63x 63x 21x 21x 21x 21x 21x 39x 39x 39x 39x 39x 39x 121x 121x 129x 121x 250x 250x 121x | /**
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
/**
* Touch events state machine.
*
* Keeps track of the active pointers and allows them to be reflected in touch events.
*/
let isGesture = false;
const activeTouches = new Map();
export function addTouch(touch) {
const identifier = touch.identifier;
const target = touch.target;
if (!activeTouches.has(target)) {
activeTouches.set(target, new Map());
}
Iif (activeTouches.get(target).get(identifier)) {
// Do not allow existing touches to be overwritten
console.error(
'Touch with identifier %s already exists. Did not record touch start.',
identifier
);
} else {
activeTouches.get(target).set(identifier, touch);
}
isGesture = activeTouches.size > 1;
}
export function updateTouch(touch) {
const identifier = touch.identifier;
const target = touch.target;
Eif (activeTouches.get(target) != null) {
activeTouches.get(target).set(identifier, touch);
isGesture = true;
} else {
console.error(
'Touch with identifier %s does not exist. Cannot record touch move without a touch start.',
identifier
);
}
}
export function removeTouch(touch) {
const identifier = touch.identifier;
const target = touch.target;
Eif (activeTouches.get(target) != null) {
Eif (activeTouches.get(target).has(identifier)) {
activeTouches.get(target).delete(identifier);
} else {
console.error(
'Touch with identifier %s does not exist. Cannot record touch end without a touch start.',
identifier
);
}
}
return isGesture;
}
export function getTouches() {
const touches = [];
activeTouches.forEach((_, target) => {
touches.push(...getTargetTouches(target));
});
return touches;
}
export function getTargetTouches(target) {
Eif (activeTouches.get(target) != null) {
return Array.from(activeTouches.get(target).values());
}
return [];
}
export function clear() {
activeTouches.clear();
}
|