1 | const euclideanDistance = require('./euclidean_distance');
|
2 |
|
3 | const FINE_TOLERANCE = 4;
|
4 | const GROSS_TOLERANCE = 12;
|
5 | const INTERVAL = 500;
|
6 |
|
7 | module.exports = function isClick(start, end, options = {}) {
|
8 | const fineTolerance = (options.fineTolerance != null) ? options.fineTolerance : FINE_TOLERANCE;
|
9 | const grossTolerance = (options.grossTolerance != null) ? options.grossTolerance : GROSS_TOLERANCE;
|
10 | const interval = (options.interval != null) ? options.interval : INTERVAL;
|
11 |
|
12 | start.point = start.point || end.point;
|
13 | start.time = start.time || end.time;
|
14 | const moveDistance = euclideanDistance(start.point, end.point);
|
15 |
|
16 | return moveDistance < fineTolerance ||
|
17 | (moveDistance < grossTolerance && (end.time - start.time) < interval);
|
18 | };
|