mirror of
https://github.com/Pomax/BezierInfo-2.git
synced 2025-09-02 12:54:23 +02:00
finally.
This commit is contained in:
@@ -93,12 +93,11 @@ class BaseAPI {
|
|||||||
const left = evt.target.offsetLeft,
|
const left = evt.target.offsetLeft,
|
||||||
top = evt.target.offsetTop;
|
top = evt.target.offsetTop;
|
||||||
|
|
||||||
let x, y;
|
let x, y;
|
||||||
|
|
||||||
if (evt.targetTouches) {
|
if (evt.targetTouches) {
|
||||||
const touch = evt.targetTouches;
|
const touch = evt.targetTouches;
|
||||||
for (let i=0; i<touch.length; i++) {
|
for (let i=0; i<touch.length; i++) {
|
||||||
console.log(touch[i]);
|
|
||||||
if (!touch[i] || !touch[i].pageX) continue;
|
if (!touch[i] || !touch[i].pageX) continue;
|
||||||
x = touch[i].pageX - left;
|
x = touch[i].pageX - left;
|
||||||
y = touch[i].pageY - top;
|
y = touch[i].pageY - top;
|
||||||
|
@@ -4,6 +4,9 @@ import { Vector } from "./types/vector.js";
|
|||||||
import { Shape } from "./util/shape.js";
|
import { Shape } from "./util/shape.js";
|
||||||
import { BaseAPI } from "./base-api.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.
|
* Our Graphics API, which is the "public" side of the API.
|
||||||
*/
|
*/
|
||||||
@@ -37,17 +40,13 @@ class GraphicsAPI extends BaseAPI {
|
|||||||
onMouseDown(evt) {
|
onMouseDown(evt) {
|
||||||
super.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];
|
p = this.moveable[i];
|
||||||
|
d = new Vector(p).dist(this.cursor);
|
||||||
console.log(`m check:`, p, this.cursor);
|
if (d <= cdist) {
|
||||||
|
|
||||||
if (new Vector(p).dist(this.cursor) <= cdist) {
|
|
||||||
this.currentPoint = p;
|
this.currentPoint = p;
|
||||||
console.log(`current point found`);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -76,7 +75,6 @@ class GraphicsAPI extends BaseAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setMovable(points) {
|
setMovable(points) {
|
||||||
console.log(points);
|
|
||||||
points.forEach((p) => this.moveable.push(p));
|
points.forEach((p) => this.moveable.push(p));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user