* velocity is calculated every x ms * @param {Object} session * @param {Object} input
(session, input)
| 51948 | |
| 51949 | |
| 51950 | function computeIntervalInputData(session, input) { |
| 51951 | var last = session.lastInterval || input, |
| 51952 | deltaTime = input.timeStamp - last.timeStamp, |
| 51953 | velocity, |
| 51954 | velocityX, |
| 51955 | velocityY, |
| 51956 | direction; |
| 51957 | |
| 51958 | if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) { |
| 51959 | var deltaX = input.deltaX - last.deltaX; |
| 51960 | var deltaY = input.deltaY - last.deltaY; |
| 51961 | var v = getVelocity(deltaTime, deltaX, deltaY); |
| 51962 | velocityX = v.x; |
| 51963 | velocityY = v.y; |
| 51964 | velocity = abs(v.x) > abs(v.y) ? v.x : v.y; |
| 51965 | direction = getDirection(deltaX, deltaY); |
| 51966 | session.lastInterval = input; |
| 51967 | } else { |
| 51968 | // use latest velocity info if it doesn't overtake a minimum period |
| 51969 | velocity = last.velocity; |
| 51970 | velocityX = last.velocityX; |
| 51971 | velocityY = last.velocityY; |
| 51972 | direction = last.direction; |
| 51973 | } |
| 51974 | |
| 51975 | input.velocity = velocity; |
| 51976 | input.velocityX = velocityX; |
| 51977 | input.velocityY = velocityY; |
| 51978 | input.direction = direction; |
| 51979 | } |
| 51980 | /** |
| 51981 | * create a simple clone from the input used for storage of firstInput and firstMultiple |
| 51982 | * @param {Object} input |
no test coverage detected