1
0
mirror of https://github.com/Pomax/BezierInfo-2.git synced 2025-09-02 21:02:49 +02:00
This commit is contained in:
Pomax
2020-08-08 13:29:56 -07:00
parent 975dcb1168
commit b85a87386b
2 changed files with 8 additions and 11 deletions

View File

@@ -98,7 +98,6 @@ class BaseAPI {
if (evt.targetTouches) {
const touch = evt.targetTouches;
for (let i=0; i<touch.length; i++) {
console.log(touch[i]);
if (!touch[i] || !touch[i].pageX) continue;
x = touch[i].pageX - left;
y = touch[i].pageY - top;

View File

@@ -4,6 +4,9 @@ import { Vector } from "./types/vector.js";
import { Shape } from "./util/shape.js";
import { BaseAPI } from "./base-api.js";
const MOUSE_PRECISION_ZONE = 5;
const TOUCH_PRECISION_ZONE = 30;
/**
* Our Graphics API, which is the "public" side of the API.
*/
@@ -37,17 +40,13 @@ class GraphicsAPI extends BaseAPI {
onMouseDown(evt) {
super.onMouseDown(evt);
const cdist = evt.targetTouches ? 10 : 5;
const cdist = evt.targetTouches ? TOUCH_PRECISION_ZONE : MOUSE_PRECISION_ZONE;
for (let i = 0, e = this.moveable.length, p; i < e; i++) {
for (let i = 0, e = this.moveable.length, p, d; i < e; i++) {
p = this.moveable[i];
console.log(`m check:`, p, this.cursor);
if (new Vector(p).dist(this.cursor) <= cdist) {
d = new Vector(p).dist(this.cursor);
if (d <= cdist) {
this.currentPoint = p;
console.log(`current point found`);
break;
}
}
@@ -76,7 +75,6 @@ class GraphicsAPI extends BaseAPI {
}
setMovable(points) {
console.log(points);
points.forEach((p) => this.moveable.push(p));
}