@any-touch/compute
Advanced tools
Comparing version 0.7.9 to 0.8.0
import type { Input, directionString } from '@any-touch/shared'; | ||
declare function computeDistance(): (input: Input) => { | ||
declare function ComputeDistance(): (input: Input) => { | ||
displacementX: number; | ||
@@ -10,5 +10,5 @@ displacementY: number; | ||
}; | ||
declare namespace computeDistance { | ||
declare namespace ComputeDistance { | ||
var _id: string; | ||
} | ||
export default computeDistance; | ||
export default ComputeDistance; |
import type { Input } from '@any-touch/shared'; | ||
declare function computeMaxLength(): (input: Input) => { | ||
declare function ComputeMaxLength(): (input: Input) => { | ||
maxPointLength: number; | ||
}; | ||
declare namespace computeMaxLength { | ||
declare namespace ComputeMaxLength { | ||
var _id: string; | ||
} | ||
export default computeMaxLength; | ||
export default ComputeMaxLength; |
@@ -1,8 +0,6 @@ | ||
export { default as computeAngle } from './computeAngle'; | ||
export { default as ComputeAngle } from './ComputeAngle'; | ||
export { default as ComputeDeltaXY } from './ComputeDeltaXY'; | ||
export { default as ComputeDistance } from './ComputeDistance'; | ||
export { default as ComputeMaxLength } from './ComputeMaxLength'; | ||
export { default as computeScale } from './computeScale'; | ||
export { default as ComputeScale } from './ComputeScale'; | ||
export { default as ComputeVAndDir } from './ComputeVAndDir'; | ||
export { default as computeVector } from './computeVector'; | ||
export { default as ComputeVectorForMutli } from './ComputeVectorForMutli'; |
import { getAngle, radianToAngle, getVLength, getDirection } from '@any-touch/vector'; | ||
import { INPUT_START, INPUT_MOVE, CLIENT_X, CLIENT_Y, NONE, round2, COMPUTE_INTERVAL } from '@any-touch/shared'; | ||
import { CLIENT_X, CLIENT_Y, INPUT_START, INPUT_MOVE, NONE, round2, COMPUTE_INTERVAL } from '@any-touch/shared'; | ||
function computeAngle (_a) { | ||
var startV = _a.startV, prevV = _a.prevV, activeV = _a.activeV; | ||
var deltaAngle = Math.round(getAngle(activeV, prevV)); | ||
var angle = Math.round(getAngle(activeV, startV)); | ||
return { angle: angle, deltaAngle: deltaAngle }; | ||
function computeVector(input) { | ||
return { | ||
x: input.points[1][CLIENT_X] - input.points[0][CLIENT_X], | ||
y: input.points[1][CLIENT_Y] - input.points[0][CLIENT_Y] | ||
}; | ||
} | ||
function _computeVectorForMutli (input) { | ||
var prevInput = input.prevInput, startMultiInput = input.startMultiInput; | ||
if (void 0 !== startMultiInput && | ||
void 0 !== prevInput && | ||
input.id !== startMultiInput.id && | ||
1 < prevInput.pointLength && | ||
1 < input.pointLength) { | ||
return { | ||
startV: computeVector(startMultiInput), | ||
prevV: computeVector(prevInput), | ||
activeV: computeVector(input) | ||
}; | ||
} | ||
} | ||
function ComputeAngle() { | ||
return function (input) { | ||
var _vs = (input === null || input === void 0 ? void 0 : input._vs) || _computeVectorForMutli(input); | ||
if (void 0 !== _vs && _vs.activeV) { | ||
var prevV = _vs.prevV, startV = _vs.startV, activeV = _vs.activeV; | ||
var deltaAngle = Math.round(getAngle(activeV, prevV)); | ||
var angle = Math.round(getAngle(activeV, startV)); | ||
return { angle: angle, deltaAngle: deltaAngle, _vs: _vs }; | ||
} | ||
}; | ||
} | ||
ComputeAngle._id = "a"; | ||
function ComputeDeltaXY() { | ||
@@ -28,5 +55,5 @@ return function (input) { | ||
} | ||
ComputeDeltaXY._id = "ComputeDeltaXY"; | ||
ComputeDeltaXY._id = "b"; | ||
function computeDistance() { | ||
function ComputeDistance() { | ||
var displacementX = 0; | ||
@@ -61,5 +88,5 @@ var displacementY = 0; | ||
} | ||
computeDistance._id = "computeDistance"; | ||
ComputeDistance._id = "c"; | ||
function computeMaxLength() { | ||
function ComputeMaxLength() { | ||
var maxPointLength = 0; | ||
@@ -74,10 +101,16 @@ return function (input) { | ||
} | ||
computeMaxLength._id = "computeMaxLength"; | ||
ComputeMaxLength._id = "d"; | ||
function computeScale(_a) { | ||
var startV = _a.startV, prevV = _a.prevV, activeV = _a.activeV; | ||
var deltaScale = round2(getVLength(activeV) / getVLength(prevV)); | ||
var scale = round2(getVLength(activeV) / getVLength(startV)); | ||
return { scale: scale, deltaScale: deltaScale }; | ||
function ComputeScale() { | ||
return function (input) { | ||
var _vs = (input === null || input === void 0 ? void 0 : input._vs) || _computeVectorForMutli(input); | ||
if (void 0 !== _vs && _vs.activeV) { | ||
var prevV = _vs.prevV, startV = _vs.startV, activeV = _vs.activeV; | ||
var deltaScale = round2(getVLength(activeV) / getVLength(prevV)); | ||
var scale = round2(getVLength(activeV) / getVLength(startV)); | ||
return { scale: scale, deltaScale: deltaScale, _vs: _vs }; | ||
} | ||
}; | ||
} | ||
ComputeScale._id = "e"; | ||
@@ -103,3 +136,3 @@ function ComputeVAndDir() { | ||
velocityY = Math.abs(speedY); | ||
direction = getDirection(deltaX, deltaY) || (direction); | ||
direction = getDirection(deltaX, deltaY) || direction; | ||
_lastValidInput = input; | ||
@@ -111,29 +144,4 @@ } | ||
} | ||
ComputeVAndDir._id = "ComputeVAndDir"; | ||
ComputeVAndDir._id = "f"; | ||
function computeVector(input) { | ||
return { | ||
x: input.points[1][CLIENT_X] - input.points[0][CLIENT_X], | ||
y: input.points[1][CLIENT_Y] - input.points[0][CLIENT_Y] | ||
}; | ||
} | ||
function ComputeVectorForMutli() { | ||
return function (input) { | ||
var prevInput = input.prevInput, startMultiInput = input.startMultiInput; | ||
if (void 0 !== startMultiInput && | ||
void 0 !== prevInput && | ||
input.id !== startMultiInput.id && | ||
1 < prevInput.pointLength && | ||
1 < input.pointLength) { | ||
return { | ||
startV: computeVector(startMultiInput), | ||
prevV: computeVector(prevInput), | ||
activeV: computeVector(input) | ||
}; | ||
} | ||
}; | ||
} | ||
ComputeVectorForMutli._id = "ComputeVectorForMutli"; | ||
export { ComputeDeltaXY, computeDistance as ComputeDistance, computeMaxLength as ComputeMaxLength, ComputeVAndDir, ComputeVectorForMutli, computeAngle, computeScale, computeVector }; | ||
export { ComputeAngle, ComputeDeltaXY, ComputeDistance, ComputeMaxLength, ComputeScale, ComputeVAndDir }; |
@@ -1,1 +0,1 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@any-touch/vector"),e=require("@any-touch/shared");function n(){return function(e){var n=e.prevInput,r=0,o=0,a=0;if(void 0!==n&&(r=e.x-n.x,o=e.y-n.y,0!==r||0!==o)){var i=Math.sqrt(Math.pow(r,2)+Math.pow(o,2));a=Math.round(t.radianToAngle(Math.acos(Math.abs(r)/i)))}return{deltaX:r,deltaY:o,deltaXYAngle:a}}}function r(){var n=0,r=0,o=0,a=0,i=0,u=e.NONE;return function(p){var s=p.stage,c=p.startInput;return e.INPUT_START===s?(n=0,r=0,o=0,a=0,i=0,u=e.NONE):e.INPUT_MOVE===s&&(n=Math.round(p.points[0][e.CLIENT_X]-c.points[0][e.CLIENT_X]),r=Math.round(p.points[0][e.CLIENT_Y]-c.points[0][e.CLIENT_Y]),o=Math.abs(n),a=Math.abs(r),i=Math.round(t.getVLength({x:o,y:a})),u=t.getDirection(n,r)),{displacementX:n,displacementY:r,distanceX:o,distanceY:a,distance:i,overallDirection:u}}}function o(){var t=0;return function(n){var r=n.stage;return e.INPUT_START===r&&(t=n.pointLength),{maxPointLength:t}}}function a(){var n,r,o=0,a=0,i=0,u=0;return function(p){if(void 0!==p){var s=p.stage;r=r||p.startInput;var c=p.timestamp-r.timestamp;if(e.INPUT_MOVE===s&&e.COMPUTE_INTERVAL<c){var d=p.x-r.x,h=p.y-r.y;i=Math.round(d/c*100)/100,u=Math.round(h/c*100)/100,o=Math.abs(i),a=Math.abs(u),n=t.getDirection(d,h)||n,r=p}}return{velocityX:o,velocityY:a,speedX:i,speedY:u,direction:n}}}function i(t){return{x:t.points[1][e.CLIENT_X]-t.points[0][e.CLIENT_X],y:t.points[1][e.CLIENT_Y]-t.points[0][e.CLIENT_Y]}}function u(){return function(t){var e=t.prevInput,n=t.startMultiInput;if(void 0!==n&&void 0!==e&&t.id!==n.id&&1<e.pointLength&&1<t.pointLength)return{startV:i(n),prevV:i(e),activeV:i(t)}}}n._id="ComputeDeltaXY",r._id="computeDistance",o._id="computeMaxLength",a._id="ComputeVAndDir",u._id="ComputeVectorForMutli",exports.ComputeDeltaXY=n,exports.ComputeDistance=r,exports.ComputeMaxLength=o,exports.ComputeVAndDir=a,exports.ComputeVectorForMutli=u,exports.computeAngle=function(e){var n=e.startV,r=e.prevV,o=e.activeV,a=Math.round(t.getAngle(o,r));return{angle:Math.round(t.getAngle(o,n)),deltaAngle:a}},exports.computeScale=function(n){var r=n.startV,o=n.prevV,a=n.activeV,i=e.round2(t.getVLength(a)/t.getVLength(o));return{scale:e.round2(t.getVLength(a)/t.getVLength(r)),deltaScale:i}},exports.computeVector=i; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@any-touch/vector"),e=require("@any-touch/shared");function n(t){return{x:t.points[1][e.CLIENT_X]-t.points[0][e.CLIENT_X],y:t.points[1][e.CLIENT_Y]-t.points[0][e.CLIENT_Y]}}function r(t){var e=t.prevInput,r=t.startMultiInput;if(void 0!==r&&void 0!==e&&t.id!==r.id&&1<e.pointLength&&1<t.pointLength)return{startV:n(r),prevV:n(e),activeV:n(t)}}function a(){return function(e){var n=(null==e?void 0:e._vs)||r(e);if(void 0!==n&&n.activeV){var a=n.prevV,i=n.startV,o=n.activeV,u=Math.round(t.getAngle(o,a));return{angle:Math.round(t.getAngle(o,i)),deltaAngle:u,_vs:n}}}}function i(){return function(e){var n=e.prevInput,r=0,a=0,i=0;if(void 0!==n&&(r=e.x-n.x,a=e.y-n.y,0!==r||0!==a)){var o=Math.sqrt(Math.pow(r,2)+Math.pow(a,2));i=Math.round(t.radianToAngle(Math.acos(Math.abs(r)/o)))}return{deltaX:r,deltaY:a,deltaXYAngle:i}}}function o(){var n=0,r=0,a=0,i=0,o=0,u=e.NONE;return function(s){var d=s.stage,p=s.startInput;return e.INPUT_START===d?(n=0,r=0,a=0,i=0,o=0,u=e.NONE):e.INPUT_MOVE===d&&(n=Math.round(s.points[0][e.CLIENT_X]-p.points[0][e.CLIENT_X]),r=Math.round(s.points[0][e.CLIENT_Y]-p.points[0][e.CLIENT_Y]),a=Math.abs(n),i=Math.abs(r),o=Math.round(t.getVLength({x:a,y:i})),u=t.getDirection(n,r)),{displacementX:n,displacementY:r,distanceX:a,distanceY:i,distance:o,overallDirection:u}}}function u(){var t=0;return function(n){var r=n.stage;return e.INPUT_START===r&&(t=n.pointLength),{maxPointLength:t}}}function s(){return function(n){var a=(null==n?void 0:n._vs)||r(n);if(void 0!==a&&a.activeV){var i=a.prevV,o=a.startV,u=a.activeV,s=e.round2(t.getVLength(u)/t.getVLength(i));return{scale:e.round2(t.getVLength(u)/t.getVLength(o)),deltaScale:s,_vs:a}}}}function d(){var n,r,a=0,i=0,o=0,u=0;return function(s){if(void 0!==s){var d=s.stage;r=r||s.startInput;var p=s.timestamp-r.timestamp;if(e.INPUT_MOVE===d&&e.COMPUTE_INTERVAL<p){var v=s.x-r.x,c=s.y-r.y;o=Math.round(v/p*100)/100,u=Math.round(c/p*100)/100,a=Math.abs(o),i=Math.abs(u),n=t.getDirection(v,c)||n,r=s}}return{velocityX:a,velocityY:i,speedX:o,speedY:u,direction:n}}}a._id="a",i._id="b",o._id="c",u._id="d",s._id="e",d._id="f",exports.ComputeAngle=a,exports.ComputeDeltaXY=i,exports.ComputeDistance=o,exports.ComputeMaxLength=u,exports.ComputeScale=s,exports.ComputeVAndDir=d; |
{ | ||
"name": "@any-touch/compute", | ||
"version": "0.7.9", | ||
"version": "0.8.0", | ||
"main": "dist/index.js", | ||
@@ -14,4 +14,4 @@ "module": "dist/index.es.js", | ||
"dependencies": { | ||
"@any-touch/shared": "^0.7.9", | ||
"@any-touch/vector": "^0.7.9", | ||
"@any-touch/shared": "^0.8.0", | ||
"@any-touch/vector": "^0.8.0", | ||
"tslib": "^1.9.3" | ||
@@ -22,3 +22,3 @@ }, | ||
"sideEffects": false, | ||
"gitHead": "4d795d9ac1c0cf597db9bc070284f3de7578e5fd" | ||
"gitHead": "2bc02cd25dc78562a2b61c95e2d481ac718e805e" | ||
} |
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
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
12149
234
13
+ Added@any-touch/shared@0.8.0(transitive)
+ Added@any-touch/vector@0.8.0(transitive)
- Removed@any-touch/shared@0.7.9(transitive)
- Removed@any-touch/vector@0.7.9(transitive)
Updated@any-touch/shared@^0.8.0
Updated@any-touch/vector@^0.8.0