MCPcopy Create free account
hub / github.com/dcloudio/mui / calIntervalTouchData

Function calIntervalTouchData

js/mui.gestures.js:281–312  ·  view source on GitHub ↗
(touch)

Source from the content-addressed store, hash-verified

279 };
280 var CAL_INTERVAL = 25;
281 var calIntervalTouchData = function(touch) {
282 var session = $.gestures.session;
283 var last = session.lastInterval || touch;
284 var deltaTime = touch.timestamp - last.timestamp;
285 var velocity;
286 var velocityX;
287 var velocityY;
288 var direction;
289
290 if (touch.gesture.type != $.EVENT_CANCEL && (deltaTime > CAL_INTERVAL || last.velocity === undefined)) {
291 var deltaX = last.deltaX - touch.deltaX;
292 var deltaY = last.deltaY - touch.deltaY;
293
294 var v = getVelocity(deltaTime, deltaX, deltaY);
295 velocityX = v.x;
296 velocityY = v.y;
297 velocity = (abs(v.x) > abs(v.y)) ? v.x : v.y;
298 direction = getDirection(deltaX, deltaY) || last.direction;
299
300 session.lastInterval = touch;
301 } else {
302 velocity = last.velocity;
303 velocityX = last.velocityX;
304 velocityY = last.velocityY;
305 direction = last.direction;
306 }
307
308 touch.velocity = velocity;
309 touch.velocityX = velocityX;
310 touch.velocityY = velocityY;
311 touch.direction = direction;
312 };
313 var targetIds = {};
314 var convertTouches = function(touches) {
315 for (var i = 0; i < touches.length; i++) {

Callers 1

calTouchDataFunction · 0.70

Calls 2

getVelocityFunction · 0.70
getDirectionFunction · 0.70

Tested by

no test coverage detected