Debian Codegraph @

src/inputjs/simple-clone-input-data.js

raw
1 import { now,round } from '../utils/utils-consts';
2 import getCenter from './get-center';
3
4 /**
5 * @private
6 * create a simple clone from the input used for storage of firstInput and firstMultiple
7 * @param {Object} input
8 * @returns {Object} clonedInputData
9 */
10 export default function simpleCloneInputData(input) {
11 // make a simple copy of the pointers because we will get a reference if we don't
12 // we only need clientXY for the calculations
13 let pointers = [];
14 let i = 0;
15 while (i < input.pointers.length) {
16 pointers[i] = {
17 clientX: round(input.pointers[i].clientX),
18 clientY: round(input.pointers[i].clientY)
19 };
20 i++;
21 }
22
23 return {
24 timeStamp: now(),
25 pointers,
26 center: getCenter(pointers),
27 deltaX: input.deltaX,
28 deltaY: input.deltaY
29 };
30 }