@any-touch/pinch
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -1,3 +0,2 @@ | ||
import { Input, CommonEmitFunction } from '@any-touch/shared'; | ||
import Recognizer from '@any-touch/recognizer'; | ||
import type { RecognizerOptions, RecognizerFunction } from '@any-touch/shared'; | ||
declare const DEFAULT_OPTIONS: { | ||
@@ -8,16 +7,3 @@ name: string; | ||
}; | ||
export default class extends Recognizer { | ||
constructor(options: Partial<typeof DEFAULT_OPTIONS>); | ||
/** | ||
* 识别条件 | ||
* @param {AnyTouchEvent} 计算数据 | ||
* @param {(isRecognized: boolean) => void}} 接收是否识别状态 | ||
*/ | ||
test(input: Input): boolean; | ||
/** | ||
* 开始识别 | ||
* @param {Input} 输入 | ||
*/ | ||
recognize(input: Input, emit: CommonEmitFunction): void; | ||
} | ||
export default function Pinch(options?: RecognizerOptions<typeof DEFAULT_OPTIONS>): ReturnType<RecognizerFunction>; | ||
export {}; |
@@ -1,4 +0,4 @@ | ||
import { __extends, __assign } from 'tslib'; | ||
import { ComputeVectorForMutli, computeScale } from '@any-touch/compute'; | ||
import Recognizer, { recognizeForPressMoveLike } from '@any-touch/recognizer'; | ||
import { __read } from 'tslib'; | ||
import { ComputeScale } from '@any-touch/compute'; | ||
import createContext, { canResetStatusForPressMoveLike, recognizeForPressMoveLike } from '@any-touch/recognizer'; | ||
@@ -10,24 +10,22 @@ var DEFAULT_OPTIONS = { | ||
}; | ||
var default_1 = (function (_super) { | ||
__extends(default_1, _super); | ||
function default_1(options) { | ||
return _super.call(this, __assign(__assign({}, DEFAULT_OPTIONS), options)) || this; | ||
function Pinch(options) { | ||
var _context = createContext(DEFAULT_OPTIONS, options); | ||
var _isRecognized = false; | ||
function _test(computed) { | ||
var pointLength = computed.pointLength, scale = computed.scale; | ||
return (_context.pointLength === pointLength && | ||
void 0 !== scale && | ||
(_context.threshold < Math.abs(scale - 1) || _isRecognized)); | ||
} | ||
default_1.prototype.test = function (input) { | ||
var pointLength = input.pointLength; | ||
var scale = this.computed.scale; | ||
return this.isValidPointLength(pointLength) | ||
&& void 0 !== scale | ||
&& (this.options.threshold < Math.abs(scale - 1) || this.isRecognized); | ||
}; | ||
default_1.prototype.recognize = function (input, emit) { | ||
var computed = this.compute([ComputeVectorForMutli], input); | ||
if ("activeV" in computed) { | ||
this.computed = __assign(__assign({}, this.computed), computeScale(computed)); | ||
} | ||
recognizeForPressMoveLike(this, input, emit); | ||
}; | ||
return default_1; | ||
}(Recognizer)); | ||
function _recognize(computed, emit) { | ||
_context.status = canResetStatusForPressMoveLike(_context.status); | ||
recognizeForPressMoveLike(computed, _test, _context.name, _context.status, emit, function (_a) { | ||
var _b = __read(_a, 2), isRecognized = _b[0], status = _b[1]; | ||
_context.status = status; | ||
_isRecognized = isRecognized; | ||
}); | ||
} | ||
return [_context, _recognize, [ComputeScale]]; | ||
} | ||
export default default_1; | ||
export default Pinch; |
@@ -1,1 +0,1 @@ | ||
if (process.env.NODE_ENV === 'development') {module.exports = require('./index.dev.js');} else {module.exports = require('./index.prod.js');} | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("tslib"),r=require("@any-touch/compute"),n=require("@any-touch/recognizer"),o=(e=n)&&"object"==typeof e&&"default"in e?e.default:e,s={name:"pinch",threshold:0,pointLength:2};exports.default=function(e){var u=o(s,e),a=!1;function i(e){var t=e.pointLength,r=e.scale;return u.pointLength===t&&void 0!==r&&(u.threshold<Math.abs(r-1)||a)}return[u,function(e,r){u.status=n.canResetStatusForPressMoveLike(u.status),n.recognizeForPressMoveLike(e,i,u.name,u.status,r,(function(e){var r=t.__read(e,2),n=r[0],o=r[1];u.status=o,a=n}))},[r.ComputeScale]]}; |
{ | ||
"name": "@any-touch/pinch", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "any-touch的识别器, 用来识别捏合手势.", | ||
@@ -17,4 +17,4 @@ "main": "./dist/index", | ||
"dependencies": { | ||
"@any-touch/compute": "^1.0.1", | ||
"@any-touch/recognizer": "^1.0.1" | ||
"@any-touch/compute": "^1.0.2", | ||
"@any-touch/recognizer": "^1.0.2" | ||
}, | ||
@@ -25,3 +25,3 @@ "publishConfig": { | ||
"sideEffects": false, | ||
"gitHead": "daec688784b1b67c7e427a0b474deae8773f54e6" | ||
"gitHead": "a11a02a110bf20b6163b5b716b60b87de3b967da" | ||
} |
@@ -0,0 +0,0 @@ # @any-touch/pinch |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
1
4519
6
39
Updated@any-touch/compute@^1.0.2
Updated@any-touch/recognizer@^1.0.2