This commit is contained in:
Raphael 2022-06-11 17:56:32 +02:00
parent a44a66cea5
commit 92705e55ce
2 changed files with 21 additions and 1 deletions

View File

@ -38,6 +38,14 @@ class Point {
return this.#x === 0 && this.#y === 0;
}
set x(newX) {
this.#x = newX;
}
set y(newY) {
this.#y = newY;
}
/**
* Get a Point object from an event
* @param {event} e

View File

@ -244,7 +244,12 @@ const whiteboard = {
_this.ctx.globalCompositeOperation = _this.oldGCO;
let currentPos = Point.fromEvent(e);
if (_this.tool !== "hand") {
console.log(currentPos.x, currentPos.y, _this.viewCoords.x, _this.viewCoords.y);
currentPos.x += _this.viewCoords.x;
currentPos.y += _this.viewCoords.y;
console.log(currentPos.x, currentPos.y);
}
if (currentPos.isZeroZero) {
_this.sendFunction({
t: "cursor",
@ -285,6 +290,7 @@ const whiteboard = {
_this.drawBuffer = [];
_this.textContainer.empty();
_this.loadData(dbCp); // draw old content in
console.log(_this.viewCoords.x, _this.viewCoords.y);
} else if (_this.tool === "pen") {
_this.pushPointSmoothPen(currentPos.x, currentPos.y);
@ -493,6 +499,12 @@ const whiteboard = {
}
let currentPos = Point.fromEvent(e);
if (_this.tool !== "hand") {
console.log(currentPos.x, currentPos.y, _this.viewCoords.x, _this.viewCoords.y);
currentPos.x -= _this.viewCoords.x;
currentPos.y -= _this.viewCoords.y;
console.log(currentPos.x, currentPos.y);
}
window.requestAnimationFrame(function () {
// update position