Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@any-touch/tap

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@any-touch/tap - npm Package Compare versions

Comparing version 0.7.4 to 0.7.5

0

dist/index.d.ts

@@ -0,0 +0,0 @@ import { Point, Input } from '@any-touch/shared';

@@ -0,0 +0,0 @@ import { __extends, __assign } from 'tslib';

2

dist/index.js

@@ -1,1 +0,1 @@

"use strict";function _interopDefault(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var tslib=require("tslib"),shared=require("@any-touch/shared"),Recognizer=_interopDefault(require("@any-touch/recognizer")),vector=require("@any-touch/vector"),compute=require("@any-touch/compute"),DEFAULT_OPTIONS={name:"tap",pointLength:1,tapTimes:1,waitNextTapTime:300,maxDistance:2,maxDistanceFromPrevTap:9,maxPressTime:250},default_1=function(t){function e(e){var i=t.call(this,tslib.__assign(tslib.__assign({},DEFAULT_OPTIONS),e))||this;return i.tapCount=0,i}return tslib.__extends(e,t),e.prototype._isValidDistanceFromPrevTap=function(t){if(void 0!==this.prevTapPoint){var e=vector.getVLength({x:t.x-this.prevTapPoint.x,y:t.y-this.prevTapPoint.y});return this.prevTapPoint=t,this.options.maxDistanceFromPrevTap>=e}return this.prevTapPoint=t,!0},e.prototype._isValidInterval=function(){var t=performance.now();if(void 0===this.prevTapTime)return this.prevTapTime=t,!0;var e=t-this.prevTapTime;return this.prevTapTime=t,e<this.options.waitNextTapTime},e.prototype.recognize=function(t,e){var i=t.inputType,o=t.x,s=t.y;this.computed=this.compute([compute.ComputeMaxLength,compute.ComputeDistance],t),shared.INPUT_END===i&&(this.status=shared.STATUS_POSSIBLE,this.test(t)?(this.cancelCountDownToFail(),this._isValidDistanceFromPrevTap({x:o,y:s})&&this._isValidInterval()?this.tapCount++:this.tapCount=1,0==this.tapCount%this.options.tapTimes?(this.status=shared.STATUS_RECOGNIZED,e(this.options.name,tslib.__assign(tslib.__assign({},this.computed),{tapCount:this.tapCount})),this.reset()):this.countDownToFail()):(this.reset(),this.status=shared.STATUS_FAILED))},e.prototype.countDownToFail=function(){var t=this;this._countDownToFailTimer=setTimeout((function(){t.status=shared.STATUS_FAILED,t.reset()}),this.options.waitNextTapTime)},e.prototype.cancelCountDownToFail=function(){clearTimeout(this._countDownToFailTimer)},e.prototype.reset=function(){this.tapCount=0,this.prevTapPoint=void 0,this.prevTapTime=void 0},e.prototype.test=function(t){var e=t.startInput,i=t.pointLength,o=t.timestamp-e.timestamp,s=this.computed,n=s.maxPointLength,a=s.distance;return n===this.options.pointLength&&0===i&&this.options.maxDistance>=a&&this.options.maxPressTime>o},e}(Recognizer);exports.default=default_1;
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,i=require("tslib"),e=require("@any-touch/shared"),o=(t=require("@any-touch/recognizer"))&&"object"==typeof t&&"default"in t?t.default:t,s=require("@any-touch/vector"),n=require("@any-touch/compute"),a={name:"tap",pointLength:1,tapTimes:1,waitNextTapTime:300,maxDistance:2,maxDistanceFromPrevTap:9,maxPressTime:250},r=function(t){function o(e){var o=t.call(this,i.__assign(i.__assign({},a),e))||this;return o.tapCount=0,o}return i.__extends(o,t),o.prototype._isValidDistanceFromPrevTap=function(t){if(void 0!==this.prevTapPoint){var i=s.getVLength({x:t.x-this.prevTapPoint.x,y:t.y-this.prevTapPoint.y});return this.prevTapPoint=t,this.options.maxDistanceFromPrevTap>=i}return this.prevTapPoint=t,!0},o.prototype._isValidInterval=function(){var t=performance.now();if(void 0===this.prevTapTime)return this.prevTapTime=t,!0;var i=t-this.prevTapTime;return this.prevTapTime=t,i<this.options.waitNextTapTime},o.prototype.recognize=function(t,o){var s=t.inputType,a=t.x,r=t.y;this.computed=this.compute([n.ComputeMaxLength,n.ComputeDistance],t),e.INPUT_END===s&&(this.status=e.STATUS_POSSIBLE,this.test(t)?(this.cancelCountDownToFail(),this._isValidDistanceFromPrevTap({x:a,y:r})&&this._isValidInterval()?this.tapCount++:this.tapCount=1,0==this.tapCount%this.options.tapTimes?(this.status=e.STATUS_RECOGNIZED,o(this.options.name,i.__assign(i.__assign({},this.computed),{tapCount:this.tapCount})),this.reset()):this.countDownToFail()):(this.reset(),this.status=e.STATUS_FAILED))},o.prototype.countDownToFail=function(){var t=this;this._countDownToFailTimer=setTimeout((function(){t.status=e.STATUS_FAILED,t.reset()}),this.options.waitNextTapTime)},o.prototype.cancelCountDownToFail=function(){clearTimeout(this._countDownToFailTimer)},o.prototype.reset=function(){this.tapCount=0,this.prevTapPoint=void 0,this.prevTapTime=void 0},o.prototype.test=function(t){var i=t.startInput,e=t.pointLength,o=t.timestamp-i.timestamp,s=this.computed,n=s.maxPointLength,a=s.distance;return n===this.options.pointLength&&0===e&&this.options.maxDistance>=a&&this.options.maxPressTime>o},o}(o);exports.default=r;
{
"name": "@any-touch/tap",
"version": "0.7.4",
"version": "0.7.5",
"description": "any-touch的识别器, 用来识别点击手势.",

@@ -14,6 +14,6 @@ "main": "./dist/index",

"dependencies": {
"@any-touch/compute": "^0.7.4",
"@any-touch/recognizer": "^0.7.4",
"@any-touch/shared": "^0.7.4",
"@any-touch/vector": "^0.7.4"
"@any-touch/compute": "^0.7.5",
"@any-touch/recognizer": "^0.7.5",
"@any-touch/shared": "^0.7.5",
"@any-touch/vector": "^0.7.5"
},

@@ -27,3 +27,3 @@ "files": [

"sideEffects": false,
"gitHead": "20cfae8bee6e95cca8dd56799f56dd48234556c4"
"gitHead": "d4d3471e164e745d18940a2fd3192362a3a86edf"
}

@@ -0,0 +0,0 @@ # @any-touch/tap

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc