diff --git a/src/js/classes/Point.js b/src/js/classes/Point.js index 4c8fd81..36e2e7c 100644 --- a/src/js/classes/Point.js +++ b/src/js/classes/Point.js @@ -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 diff --git a/src/js/whiteboard.js b/src/js/whiteboard.js index 2024b8f..870fa48 100644 --- a/src/js/whiteboard.js +++ b/src/js/whiteboard.js @@ -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