@any-touch/compute
Advanced tools
Comparing version 2.0.0-alpha.4 to 2.0.0
@@ -8,5 +8,5 @@ import type { Input } from '@any-touch/shared'; | ||
export default function (): (input: Input) => { | ||
startVecotr: any; | ||
prevVecotr: any; | ||
activeVecotr: any; | ||
startVecotr: import("@any-touch/shared").Point; | ||
prevVecotr: import("@any-touch/shared").Point; | ||
activeVecotr: import("@any-touch/shared").Point; | ||
}; |
@@ -1,2 +0,2 @@ | ||
import{getAngle as t,radianToAngle as n,getVLength as r,getDirection as a}from"@any-touch/vector";import{TYPE_START as e,TYPE_MOVE as o,CLIENT_X as i,CLIENT_Y as u,round2 as c,COMPUTE_INTERVAL as p}from"@any-touch/shared";function s(){var n=0,r=0;return function(a,e){var o=e.prevVecotr,i=e.startVecotr,u=e.activeVecotr;return u&&(r=Math.round(t(u,o)),n=Math.round(t(u,i))),{angle:n,deltaAngle:r}}}function v(){return function(t){var r=t.prevInput,a=0,e=0,o=0;if(void 0!==r&&(a=t.x-r.x,e=t.y-r.y,0!==a||0!==e)){var i=Math.sqrt(Math.pow(a,2)+Math.pow(e,2));o=Math.round(n(Math.acos(Math.abs(a)/i)))}return{deltaX:a,deltaY:e,deltaXYAngle:o}}}function d(){var t,n=0,c=0,p=0,s=0,v=0;return function(d){var h=d.phase,f=d.startInput;return e===h?(n=0,c=0,p=0,s=0,v=0):o===h&&(n=Math.round(d.points[0][i]-f.points[0][i]),c=Math.round(d.points[0][u]-f.points[0][u]),p=Math.abs(n),s=Math.abs(c),v=Math.round(r({x:p,y:s})),t=a(n,c)),{displacementX:n,displacementY:c,distanceX:p,distanceY:s,distance:v,overallDirection:t}}}function h(){var t=1,n=1;return function(a,e){var o=e.prevVecotr,i=e.startVecotr,u=e.activeVecotr;return u&&(t=c(r(u)/r(o)),n=c(r(u)/r(i))),{scale:n,deltaScale:t}}}function f(){var t,n,r=0,e=0,o=0,i=0;return function(u){if(void 0!==u){n=n||u.startInput;var c=u.timestamp-n.timestamp;if(p<c){var s=u.x-n.x,v=u.y-n.y;o=Math.round(s/c*100)/100,i=Math.round(v/c*100)/100,r=Math.abs(o),e=Math.abs(i),t=a(s,v)||t,n=u}}return{velocityX:r,velocityY:e,speedX:o,speedY:i,direction:t}}}function M(){var t=0;return function(n){var r=n.phase;return e===r&&(t=n.pointLength),{maxPointLength:t}}}function l(t){return{x:t.points[1][i]-t.points[0][i],y:t.points[1][u]-t.points[0][u]}}function m(){var t,n,r;return function(a){var e=a.prevInput,o=a.startMultiInput;return void 0!==o&&void 0!==e&&a.id!==o.id&&1<e.pointLength&&1<a.pointLength&&(t=l(o),n=l(e),r=l(a)),{startVecotr:t,prevVecotr:n,activeVecotr:r}}}export{s as ComputeAngle,v as ComputeDeltaXY,d as ComputeDistance,M as ComputeMaxLength,h as ComputeScale,f as ComputeVAndDir,m as ComputeVectorForMutli}; | ||
import{getAngle as t,radianToAngle as n,getVLength as r,getDirection as e}from"@any-touch/vector";import{TYPE_START as a,TYPE_MOVE as o,CLIENT_X as i,CLIENT_Y as u,round2 as c,COMPUTE_INTERVAL as s}from"@any-touch/shared";function p(){var n=0,r=0;return function(e,a){var o=a.prevVecotr,i=a.startVecotr,u=a.activeVecotr;return u&&(r=Math.round(t(u,o)),n=Math.round(t(u,i))),{angle:n,deltaAngle:r}}}function v(){return function(t){var r=t.prevInput,e=0,a=0,o=0;if(void 0!==r&&(e=t.x-r.x,a=t.y-r.y,0!==e||0!==a)){var i=Math.sqrt(Math.pow(e,2)+Math.pow(a,2));o=Math.round(n(Math.acos(Math.abs(e)/i)))}return{deltaX:e,deltaY:a,deltaXYAngle:o}}}function d(){var t,n=0,c=0,s=0,p=0,v=0;return function(d){var h=d.phase,f=d.startInput;return a===h?(n=0,c=0,s=0,p=0,v=0):o===h&&(n=Math.round(d.points[0][i]-f.points[0][i]),c=Math.round(d.points[0][u]-f.points[0][u]),s=Math.abs(n),p=Math.abs(c),v=Math.round(r({x:s,y:p})),t=e(n,c)),{displacementX:n,displacementY:c,distanceX:s,distanceY:p,distance:v,overallDirection:t}}}function h(){var t=1;return function(n,e){var a=1,o=e.prevVecotr,i=e.startVecotr,u=e.activeVecotr;return u&&(a=c(r(u)/r(o)),t=c(r(u)/r(i))),{scale:t,deltaScale:a}}}function f(){var t,n,r=0,a=0,o=0,i=0;return function(u){if(void 0!==u){n=n||u.startInput;var c=u.timestamp-n.timestamp;if(s<c){var p=u.x-n.x,v=u.y-n.y;o=Math.round(p/c*100)/100,i=Math.round(v/c*100)/100,r=Math.abs(o),a=Math.abs(i),t=e(p,v)||t,n=u}}return{velocityX:r,velocityY:a,speedX:o,speedY:i,direction:t}}}function l(){var t=0;return function(n){var r=n.phase;return a===r&&(t=n.pointLength),{maxPointLength:t}}}function M(t){return{x:t.points[1][i]-t.points[0][i],y:t.points[1][u]-t.points[0][u]}}function m(){var t,n,r;return function(e){"end"==e.phase&&console.log(e.points);var a=e.prevInput,o=e.startMultiInput;return void 0!==o&&void 0!==a&&e.id!==o.id&&1<a.pointLength&&1<e.pointLength?(t=M(o),n=M(a),r=M(e)):r=void 0,{startVecotr:t,prevVecotr:n,activeVecotr:r}}}export{p as ComputeAngle,v as ComputeDeltaXY,d as ComputeDistance,l as ComputeMaxLength,h as ComputeScale,f as ComputeVAndDir,m as ComputeVectorForMutli}; | ||
//# sourceMappingURL=index.es.js.map |
@@ -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(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]}}exports.ComputeAngle=function(){var e=0,n=0;return function(r,o){var a=o.prevVecotr,i=o.startVecotr,u=o.activeVecotr;return u&&(n=Math.round(t.getAngle(u,a)),e=Math.round(t.getAngle(u,i))),{angle:e,deltaAngle:n}}},exports.ComputeDeltaXY=function(){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}}},exports.ComputeDistance=function(){var n,r=0,o=0,a=0,i=0,u=0;return function(c){var p=c.phase,s=c.startInput;return e.TYPE_START===p?(r=0,o=0,a=0,i=0,u=0):e.TYPE_MOVE===p&&(r=Math.round(c.points[0][e.CLIENT_X]-s.points[0][e.CLIENT_X]),o=Math.round(c.points[0][e.CLIENT_Y]-s.points[0][e.CLIENT_Y]),a=Math.abs(r),i=Math.abs(o),u=Math.round(t.getVLength({x:a,y:i})),n=t.getDirection(r,o)),{displacementX:r,displacementY:o,distanceX:a,distanceY:i,distance:u,overallDirection:n}}},exports.ComputeMaxLength=function(){var t=0;return function(n){var r=n.phase;return e.TYPE_START===r&&(t=n.pointLength),{maxPointLength:t}}},exports.ComputeScale=function(){var n=1,r=1;return function(o,a){var i=a.prevVecotr,u=a.startVecotr,c=a.activeVecotr;return c&&(n=e.round2(t.getVLength(c)/t.getVLength(i)),r=e.round2(t.getVLength(c)/t.getVLength(u))),{scale:r,deltaScale:n}}},exports.ComputeVAndDir=function(){var n,r,o=0,a=0,i=0,u=0;return function(c){if(void 0!==c){r=r||c.startInput;var p=c.timestamp-r.timestamp;if(e.COMPUTE_INTERVAL<p){var s=c.x-r.x,d=c.y-r.y;i=Math.round(s/p*100)/100,u=Math.round(d/p*100)/100,o=Math.abs(i),a=Math.abs(u),n=t.getDirection(s,d)||n,r=c}}return{velocityX:o,velocityY:a,speedX:i,speedY:u,direction:n}}},exports.ComputeVectorForMutli=function(){var t,e,r;return function(o){var a=o.prevInput,i=o.startMultiInput;return void 0!==i&&void 0!==a&&o.id!==i.id&&1<a.pointLength&&1<o.pointLength&&(t=n(i),e=n(a),r=n(o)),{startVecotr:t,prevVecotr:e,activeVecotr:r}}}; | ||
"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]}}exports.ComputeAngle=function(){var e=0,n=0;return function(r,o){var a=o.prevVecotr,i=o.startVecotr,u=o.activeVecotr;return u&&(n=Math.round(t.getAngle(u,a)),e=Math.round(t.getAngle(u,i))),{angle:e,deltaAngle:n}}},exports.ComputeDeltaXY=function(){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}}},exports.ComputeDistance=function(){var n,r=0,o=0,a=0,i=0,u=0;return function(c){var p=c.phase,s=c.startInput;return e.TYPE_START===p?(r=0,o=0,a=0,i=0,u=0):e.TYPE_MOVE===p&&(r=Math.round(c.points[0][e.CLIENT_X]-s.points[0][e.CLIENT_X]),o=Math.round(c.points[0][e.CLIENT_Y]-s.points[0][e.CLIENT_Y]),a=Math.abs(r),i=Math.abs(o),u=Math.round(t.getVLength({x:a,y:i})),n=t.getDirection(r,o)),{displacementX:r,displacementY:o,distanceX:a,distanceY:i,distance:u,overallDirection:n}}},exports.ComputeMaxLength=function(){var t=0;return function(n){var r=n.phase;return e.TYPE_START===r&&(t=n.pointLength),{maxPointLength:t}}},exports.ComputeScale=function(){var n=1;return function(r,o){var a=1,i=o.prevVecotr,u=o.startVecotr,c=o.activeVecotr;return c&&(a=e.round2(t.getVLength(c)/t.getVLength(i)),n=e.round2(t.getVLength(c)/t.getVLength(u))),{scale:n,deltaScale:a}}},exports.ComputeVAndDir=function(){var n,r,o=0,a=0,i=0,u=0;return function(c){if(void 0!==c){r=r||c.startInput;var p=c.timestamp-r.timestamp;if(e.COMPUTE_INTERVAL<p){var s=c.x-r.x,d=c.y-r.y;i=Math.round(s/p*100)/100,u=Math.round(d/p*100)/100,o=Math.abs(i),a=Math.abs(u),n=t.getDirection(s,d)||n,r=c}}return{velocityX:o,velocityY:a,speedX:i,speedY:u,direction:n}}},exports.ComputeVectorForMutli=function(){var t,e,r;return function(o){"end"==o.phase&&console.log(o.points);var a=o.prevInput,i=o.startMultiInput;return void 0!==i&&void 0!==a&&o.id!==i.id&&1<a.pointLength&&1<o.pointLength?(t=n(i),e=n(a),r=n(o)):r=void 0,{startVecotr:t,prevVecotr:e,activeVecotr:r}}}; |
{ | ||
"name": "@any-touch/compute", | ||
"version": "2.0.0-alpha.4", | ||
"version": "2.0.0", | ||
"main": "dist/index.js", | ||
@@ -14,4 +14,4 @@ "module": "dist/index.es.js", | ||
"dependencies": { | ||
"@any-touch/shared": "^2.0.0-alpha.4", | ||
"@any-touch/vector": "^2.0.0-alpha.4", | ||
"@any-touch/shared": "^2.0.0", | ||
"@any-touch/vector": "^2.0.0", | ||
"tslib": "^2.3.1" | ||
@@ -22,3 +22,3 @@ }, | ||
"sideEffects": false, | ||
"gitHead": "0104cf40d492a3f7927d7f7d07e7ca66cf96f455" | ||
"gitHead": "fbbe6448895509158a8a9f4e68be2e6ebc7c7fb6" | ||
} |
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
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
19596
2
Updated@any-touch/shared@^2.0.0
Updated@any-touch/vector@^2.0.0