* extend the data with some usable properties like scale, rotate, velocity etc * @param {Object} manager * @param {Object} input
(manager, input)
| 51877 | |
| 51878 | |
| 51879 | function computeInputData(manager, input) { |
| 51880 | var session = manager.session; |
| 51881 | var pointers = input.pointers; |
| 51882 | var pointersLength = pointers.length; // store the first input to calculate the distance and direction |
| 51883 | |
| 51884 | if (!session.firstInput) { |
| 51885 | session.firstInput = simpleCloneInputData(input); |
| 51886 | } // to compute scale and rotation we need to store the multiple touches |
| 51887 | |
| 51888 | |
| 51889 | if (pointersLength > 1 && !session.firstMultiple) { |
| 51890 | session.firstMultiple = simpleCloneInputData(input); |
| 51891 | } else if (pointersLength === 1) { |
| 51892 | session.firstMultiple = false; |
| 51893 | } |
| 51894 | |
| 51895 | var firstInput = session.firstInput; |
| 51896 | var firstMultiple = session.firstMultiple; |
| 51897 | var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center; |
| 51898 | var center = input.center = getCenter(pointers); |
| 51899 | input.timeStamp = now(); |
| 51900 | input.deltaTime = input.timeStamp - firstInput.timeStamp; |
| 51901 | input.angle = getAngle(offsetCenter, center); |
| 51902 | input.distance = getDistance(offsetCenter, center); |
| 51903 | computeDeltaXY(session, input); |
| 51904 | input.offsetDirection = getDirection(input.deltaX, input.deltaY); |
| 51905 | var overallVelocity = getVelocity(input.deltaTime, input.deltaX, input.deltaY); |
| 51906 | input.overallVelocityX = overallVelocity.x; |
| 51907 | input.overallVelocityY = overallVelocity.y; |
| 51908 | input.overallVelocity = abs(overallVelocity.x) > abs(overallVelocity.y) ? overallVelocity.x : overallVelocity.y; |
| 51909 | input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1; |
| 51910 | input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0; |
| 51911 | input.maxPointers = !session.prevInput ? input.pointers.length : input.pointers.length > session.prevInput.maxPointers ? input.pointers.length : session.prevInput.maxPointers; |
| 51912 | computeIntervalInputData(session, input); // find the correct target |
| 51913 | |
| 51914 | var target = manager.element; |
| 51915 | |
| 51916 | if (hasParent(input.srcEvent.target, target)) { |
| 51917 | target = input.srcEvent.target; |
| 51918 | } |
| 51919 | |
| 51920 | input.target = target; |
| 51921 | } |
| 51922 | |
| 51923 | function computeDeltaXY(session, input) { |
| 51924 | var center = input.center; |
no test coverage detected