* velocity is calculated every x ms * @param {Object} session * @param {Object} input
(session, input)
| 92925 | * @param {Object} session |
| 92926 | * @param {Object} input |
| 92927 | */ function computeIntervalInputData(session, input) { |
| 92928 | var last = session.lastInterval || input, deltaTime = input.timeStamp - last.timeStamp, velocity, velocityX, velocityY, direction; |
| 92929 | if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) { |
| 92930 | var deltaX = input.deltaX - last.deltaX; |
| 92931 | var deltaY = input.deltaY - last.deltaY; |
| 92932 | var v = getVelocity(deltaTime, deltaX, deltaY); |
| 92933 | velocityX = v.x; |
| 92934 | velocityY = v.y; |
| 92935 | velocity = abs(v.x) > abs(v.y) ? v.x : v.y; |
| 92936 | direction = getDirection(deltaX, deltaY); |
| 92937 | session.lastInterval = input; |
| 92938 | } else { |
| 92939 | // use latest velocity info if it doesn't overtake a minimum period |
| 92940 | velocity = last.velocity; |
| 92941 | velocityX = last.velocityX; |
| 92942 | velocityY = last.velocityY; |
| 92943 | direction = last.direction; |
| 92944 | } |
| 92945 | input.velocity = velocity; |
| 92946 | input.velocityX = velocityX; |
| 92947 | input.velocityY = velocityY; |
| 92948 | input.direction = direction; |
| 92949 | } |
| 92950 | /** |
| 92951 | * create a simple clone from the input used for storage of firstInput and firstMultiple |
| 92952 | * @param {Object} input |
no test coverage detected