From cb19f2bc55fedcd6e18ca080fe95420179ed5cde Mon Sep 17 00:00:00 2001 From: Ilia Choly Date: Fri, 30 Aug 2019 11:13:55 -0400 Subject: [PATCH] feat: add unit vector representation to move event output --- README.md | 4 ++++ src/collection.js | 4 ++++ types/index.d.ts | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 60ce971..4d4a0bd 100644 --- a/README.md +++ b/README.md @@ -526,6 +526,10 @@ Comes with data : radian: 1.5707963268, // angle in radian degree: 90 }, + vector: { // force unit vector + x: 0.508, + y: 3.110602869834277e-17 + }, raw: { // note: angle is the same, beyond the 50 pixel limit distance: 25.4, // distance which continues beyond the 50 pixel limit position: { // position of the finger/mouse in pixels, beyond joystick limits diff --git a/src/collection.js b/src/collection.js index 0097f5d..773de10 100644 --- a/src/collection.js +++ b/src/collection.js @@ -432,6 +432,10 @@ Collection.prototype.processOnMove = function (evt) { radian: rAngle, degree: angle }, + vector: { + x: xPosition / size, + y: - yPosition / size + }, raw: raw, instance: nipple, lockX: opts.lockX, diff --git a/types/index.d.ts b/types/index.d.ts index 577bde5..390bbba 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -159,6 +159,10 @@ export interface JoystickOutputData { x: string; y: string; }; + vector: { + x: number; + y: number; + }; raw: { distance: number; position: Position;