'use strict';

Object.defineProperty(exports, "__esModule", {
  value: true
});
exports['default'] = isClick;

var _euclidean_distance = require('./euclidean_distance');

var _euclidean_distance2 = _interopRequireDefault(_euclidean_distance);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; }

var FINE_TOLERANCE = 4; /**
                         * @文件说明: 判断是否为Click单击操作
                         * @创建人: pjtools@vip.qq.com
                         * @创建时间: 2020-05-22 14:27:14
                         */

var GROSS_TOLERANCE = 12;
var INTERVAL = 500;

function isClick(start, end) {
  var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};

  var fineTolerance = options.fineTolerance != null ? options.fineTolerance : FINE_TOLERANCE;
  var grossTolerance = options.grossTolerance != null ? options.grossTolerance : GROSS_TOLERANCE;
  var interval = options.interval != null ? options.interval : INTERVAL;

  start.point = start.point || end.point;
  start.time = start.time || end.time;
  var moveDistance = (0, _euclidean_distance2['default'])(start.point, end.point);

  return moveDistance < fineTolerance || moveDistance < grossTolerance && end.time - start.time < interval;
}