touchStore.js — react Source File
Architecture documentation for touchStore.js, a javascript file in the react codebase. 0 imports, 1 dependents.
Entity Profile
Dependency Diagram
graph LR 56f57e4a_fc42_037d_ee3b_9463227d15f3["touchStore.js"] d4066e75_dcea_2912_73ff_88e30b9530d2["domEventSequences.js"] d4066e75_dcea_2912_73ff_88e30b9530d2 --> 56f57e4a_fc42_037d_ee3b_9463227d15f3 style 56f57e4a_fc42_037d_ee3b_9463227d15f3 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
/**
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @emails react-core
*/
'use strict';
/**
* Touch events state machine.
*
* Keeps track of the active pointers and allows them to be reflected in touch events.
*/
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());
}
if (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);
}
}
export function updateTouch(touch) {
const identifier = touch.identifier;
const target = touch.target;
if (activeTouches.get(target) != null) {
activeTouches.get(target).set(identifier, touch);
} 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;
if (activeTouches.get(target) != null) {
if (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,
);
}
}
}
export function getTouches() {
const touches = [];
activeTouches.forEach((_, target) => {
touches.push(...getTargetTouches(target));
});
return touches;
}
export function getTargetTouches(target) {
if (activeTouches.get(target) != null) {
return Array.from(activeTouches.get(target).values());
}
return [];
}
export function clear() {
activeTouches.clear();
}
Domain
Subdomains
Source
Frequently Asked Questions
What does touchStore.js do?
touchStore.js is a source file in the react codebase, written in javascript. It belongs to the BabelCompiler domain, Entrypoint subdomain.
What functions are defined in touchStore.js?
touchStore.js defines 6 function(s): addTouch, clear, getTargetTouches, getTouches, removeTouch, updateTouch.
What files import touchStore.js?
touchStore.js is imported by 1 file(s): domEventSequences.js.
Where is touchStore.js in the architecture?
touchStore.js is located at packages/dom-event-testing-library/touchStore.js (domain: BabelCompiler, subdomain: Entrypoint, directory: packages/dom-event-testing-library).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free