Skip to content

Commit

Permalink
fix input
Browse files Browse the repository at this point in the history
  • Loading branch information
victorqribeiro committed Oct 15, 2019
1 parent 12b01f4 commit 424b012
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/RadialMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,10 +246,18 @@ class RadialMenu {
this.canvas.addEventListener('click', e => {

const rect = this.canvas.getBoundingClientRect();

const _x = this.w/rect.width;

const _y = this.h/rect.height;

const posX = ( rect.left + this.w2 ) * _x;

const posY = ( rect.top + this.h2 ) * _y;

const d = this.distance(e.clientX, e.clientY, rect.left+this.w2, rect.top+this.h2);
const d = this.distance(e.clientX, e.clientY, posX, posY);

let a = Math.atan2(e.clientY-(rect.top+this.h2), e.clientX-(rect.left+this.w2));
let a = Math.atan2(e.clientY-posY, e.clientX-posX);

a = a > 0 ? a : this.TWOPI+a;

Expand Down

0 comments on commit 424b012

Please sign in to comment.