Skip to content

Commit

Permalink
feat: add unit vector representation to move event output
Browse files Browse the repository at this point in the history
  • Loading branch information
icholy authored and yoannmoinet committed Sep 13, 2019
1 parent efaf725 commit cb19f2b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions src/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@ export interface JoystickOutputData {
x: string;
y: string;
};
vector: {
x: number;
y: number;
};
raw: {
distance: number;
position: Position;
Expand Down

0 comments on commit cb19f2b

Please sign in to comment.