mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-09-01 20:33:34 +02:00
finally.
This commit is contained in:
@@ -93,12 +93,11 @@ class BaseAPI {
|
||||
const left = evt.target.offsetLeft,
|
||||
top = evt.target.offsetTop;
|
||||
|
||||
let x, y;
|
||||
let x, y;
|
||||
|
||||
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;
|
||||
|
@@ -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));
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user