src/js/hammer.js
function computeIntervalInputData(session, input) {
    var last = session.lastInterval || input,
        deltaTime = input.timeStamp - last.timeStamp,
        velocity, velocityX, velocityY, direction;

    if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) {
        var deltaX = input.deltaX - last.deltaX;
        var deltaY = input.deltaY - last.deltaY;

        var v = getVelocity(deltaTime, deltaX, deltaY);
        velocityX = v.x;
        velocityY = v.y;
        velocity = (abs(v.x) > abs(v.y)) ? v.x : v.y;
        direction = getDirection(deltaX, deltaY);

        session.lastInterval = input;
    } else {
        // use latest velocity info if it doesn't overtake a minimum period
        velocity = last.velocity;
        velocityX = last.velocityX;
        velocityY = last.velocityY;
        direction = last.direction;
    }

    input.velocity = velocity;
    input.velocityX = velocityX;
    input.velocityY = velocityY;
    input.direction = direction;
}
function computeIntervalInputData(session, input) {
    var last = session.lastInterval || input,
        deltaTime = input.timeStamp - last.timeStamp,
        velocity, velocityX, velocityY, direction;

    if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined)) {
        var deltaX = input.deltaX - last.deltaX;
        var deltaY = input.deltaY - last.deltaY;

        var v = getVelocity(deltaTime, deltaX, deltaY);
        velocityX = v.x;
        velocityY = v.y;
        velocity = (abs(v.x) > abs(v.y)) ? v.x : v.y;
        direction = getDirection(deltaX, deltaY);

        session.lastInterval = input;
    } else {
        // use latest velocity info if it doesn't overtake a minimum period
        velocity = last.velocity;
        velocityX = last.velocityX;
        velocityY = last.velocityY;
        direction = last.direction;
    }

    input.velocity = velocity;
    input.velocityX = velocityX;
    input.velocityY = velocityY;
    input.direction = direction;
}
function computeIntervalInputData ( session , input ) { var last = session . lastInterval || input , deltaTime = input . timeStamp - last . timeStamp , velocity , velocityX , velocityY , direction ; if ( input . eventType != INPUT_CANCEL && ( deltaTime > COMPUTE_INTERVAL || last . velocity === undefined ) ) { var deltaX = input . deltaX - last . deltaX ; var deltaY = input . deltaY - last . deltaY ; var v = getVelocity ( deltaTime , deltaX , deltaY ) ; velocityX = v . x ; velocityY = v . y ; velocity = ( abs ( v . x ) > abs ( v . y ) ) ? v . x : v . y ; direction = getDirection ( deltaX , deltaY ) ; session . lastInterval = input ; } else { // use latest velocity info if it doesn't overtake a minimum period velocity = last . velocity ; velocityX = last . velocityX ; velocityY = last . velocityY ; direction = last . direction ; } input . velocity = velocity ; input . velocityX = velocityX ; input . velocityY = velocityY ; input . direction = direction ; }
velocity is calculated every x ms
@param {Object} session
@param {Object} input
velocity is calculated every x ms