@any-touch/pan
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 { RecognizerFunction, RecognizerOptions } from '@any-touch/shared'; | ||
declare const DEFAULT_OPTIONS: { | ||
@@ -8,17 +7,7 @@ name: string; | ||
}; | ||
export default class extends Recognizer { | ||
constructor(options: Partial<typeof DEFAULT_OPTIONS>); | ||
/** | ||
* 必要条件 | ||
* @param input 计算数据 | ||
* @return 是否是当前手势 | ||
*/ | ||
test(input: Input): boolean; | ||
/** | ||
* 开始识别 | ||
* @param input 输入 | ||
* @param emit 触发事件函数 | ||
*/ | ||
recognize(input: Input, emit: CommonEmitFunction): void; | ||
} | ||
export {}; | ||
/** | ||
* 拖拽识别器 | ||
* @param options 选项 | ||
*/ | ||
declare function Pan(options?: RecognizerOptions<typeof DEFAULT_OPTIONS>): ReturnType<RecognizerFunction>; | ||
export default Pan; |
@@ -1,4 +0,4 @@ | ||
import { __extends, __assign } from 'tslib'; | ||
import { __read } from 'tslib'; | ||
import { ComputeVAndDir, ComputeDistance, ComputeDeltaXY } from '@any-touch/compute'; | ||
import Recognizer, { recognizeForPressMoveLike } from '@any-touch/recognizer'; | ||
import createContext, { canResetStatusForPressMoveLike, recognizeForPressMoveLike } from '@any-touch/recognizer'; | ||
@@ -8,26 +8,26 @@ var DEFAULT_OPTIONS = { | ||
threshold: 10, | ||
pointLength: 1 | ||
pointLength: 1, | ||
}; | ||
var default_1 = (function (_super) { | ||
__extends(default_1, _super); | ||
function default_1(options) { | ||
return _super.call(this, __assign(__assign({}, DEFAULT_OPTIONS), options)) || this; | ||
function Pan(options) { | ||
var _context = createContext(DEFAULT_OPTIONS, options); | ||
var _isRecognized = false; | ||
function _test(computed) { | ||
var pointLength = computed.pointLength, distance = computed.distance; | ||
return (_isRecognized || _context.threshold <= distance) && _context.pointLength === pointLength; | ||
} | ||
default_1.prototype.test = function (input) { | ||
var pointLength = input.pointLength; | ||
var distance = this.computed.distance; | ||
return ((this.isRecognized || this.options.threshold < distance) && | ||
this.isValidPointLength(pointLength)); | ||
}; | ||
default_1.prototype.recognize = function (input, emit) { | ||
this.computed = this.compute([ComputeVAndDir, ComputeDistance, ComputeDeltaXY], input); | ||
var isRecognized = recognizeForPressMoveLike(this, input, emit); | ||
if (isRecognized) { | ||
var inputType = input.inputType; | ||
emit(this.options.name + this.computed.direction, this.computed); | ||
function _recognize(computed, emit) { | ||
_context.status = canResetStatusForPressMoveLike(_context.status); | ||
var isRecognizedNow = void 0 !== computed.direction && | ||
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; | ||
}); | ||
if (isRecognizedNow && void 0 !== computed.direction) { | ||
emit(_context.name + computed.direction); | ||
} | ||
}; | ||
return default_1; | ||
}(Recognizer)); | ||
} | ||
return [_context, _recognize, [ComputeVAndDir, ComputeDistance, ComputeDeltaXY]]; | ||
} | ||
export default default_1; | ||
export default Pan; |
@@ -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"),n=require("@any-touch/compute"),r=require("@any-touch/recognizer"),o=(e=r)&&"object"==typeof e&&"default"in e?e.default:e,i={name:"pan",threshold:10,pointLength:1};exports.default=function(e){var u=o(i,e),a=!1;function s(e){var t=e.pointLength,n=e.distance;return(a||u.threshold<=n)&&u.pointLength===t}return[u,function(e,n){u.status=r.canResetStatusForPressMoveLike(u.status),void 0!==e.direction&&r.recognizeForPressMoveLike(e,s,u.name,u.status,n,(function(e){var n=t.__read(e,2),r=n[0],o=n[1];u.status=o,a=r}))&&void 0!==e.direction&&n(u.name+e.direction)},[n.ComputeVAndDir,n.ComputeDistance,n.ComputeDeltaXY]]}; |
{ | ||
"name": "@any-touch/pan", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "any-touch的识别器, 用来识别拖拽手势.", | ||
@@ -17,5 +17,5 @@ "main": "./dist/index", | ||
"dependencies": { | ||
"@any-touch/compute": "^1.0.1", | ||
"@any-touch/recognizer": "^1.0.1", | ||
"@any-touch/shared": "^1.0.1" | ||
"@any-touch/compute": "^1.0.2", | ||
"@any-touch/recognizer": "^1.0.2", | ||
"@any-touch/shared": "^1.0.2" | ||
}, | ||
@@ -26,3 +26,3 @@ "publishConfig": { | ||
"sideEffects": false, | ||
"gitHead": "daec688784b1b67c7e427a0b474deae8773f54e6" | ||
"gitHead": "a11a02a110bf20b6163b5b716b60b87de3b967da" | ||
} |
@@ -0,0 +0,0 @@ # @any-touch/pan |
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
4905
6
45
Updated@any-touch/compute@^1.0.2
Updated@any-touch/recognizer@^1.0.2
Updated@any-touch/shared@^1.0.2