MCPcopy Index your code
hub / github.com/microsoft/SandDance / getCenter

Function getCenter

docs/app/js/sanddance-app.js:92978–92995  ·  view source on GitHub ↗

* get the center of all the pointers * @param {Array} pointers * @return {Object} center contains `x` and `y` properties

(pointers)

Source from the content-addressed store, hash-verified

92976 * @param {Array} pointers
92977 * @return {Object} center contains `x` and `y` properties
92978 */ function getCenter(pointers) {
92979 var pointersLength = pointers.length;
92980 // no need to loop when only one touch
92981 if (pointersLength === 1) return {
92982 x: round(pointers[0].clientX),
92983 y: round(pointers[0].clientY)
92984 };
92985 var x = 0, y = 0, i = 0;
92986 while(i < pointersLength){
92987 x += pointers[i].clientX;
92988 y += pointers[i].clientY;
92989 i++;
92990 }
92991 return {
92992 x: round(x / pointersLength),
92993 y: round(y / pointersLength)
92994 };
92995 }
92996 /**
92997 * calculate the velocity between two points. unit is in px per ms.
92998 * @param {Number} deltaTime

Callers 2

computeInputDataFunction · 0.70
simpleCloneInputDataFunction · 0.70

Calls 1

roundFunction · 0.70

Tested by

no test coverage detected