UNPKG

create-expo-cljs-app

Version:

Create a react native application with Expo and Shadow-CLJS!

34 lines (29 loc) 677 B
import { round } from '../utils/utils-consts'; /** * @private * get the center of all the pointers * @param {Array} pointers * @return {Object} center contains `x` and `y` properties */ export default function getCenter(pointers) { let pointersLength = pointers.length; // no need to loop when only one touch if (pointersLength === 1) { return { x: round(pointers[0].clientX), y: round(pointers[0].clientY) }; } let x = 0; let y = 0; let i = 0; while (i < pointersLength) { x += pointers[i].clientX; y += pointers[i].clientY; i++; } return { x: round(x / pointersLength), y: round(y / pointersLength) }; }