1
0
Fork 0
mirror of https://github.com/sbrl/Nibriboard.git synced 2018-01-10 21:33:49 +00:00

[client] Fix bugs in Mouse and Pencil.js

This commit is contained in:
Starbeamrainbowlabs 2017-04-16 16:25:32 +01:00
parent 4a55f7a941
commit e5342b07db
2 changed files with 10 additions and 6 deletions

View file

@ -47,13 +47,17 @@ class Pencil
// The time of the last push of the line to the server.
this.lastServerPush = 0;
canvas.addEventListener("mouseDown", this.handleMouseDown.bind(this));
canvas.addEventListener("mouseMove", this.handleMouseMove.bind(this));
canvas.addEventListener("mouseUp", this.handleMouseUp.bind(this));
canvas.addEventListener("mousemove", this.handleMouseMove.bind(this));
canvas.addEventListener("mouseup", this.handleMouseUp.bind(this));
}
handleMouseMove(event) {
// todo add zoom support here
// Don't draw anything if the left mouse button isn't down
if(!this.boardWindow.mouse.leftDown)
return;
var nextPoint = new Vector(
event.clientX + this.boardWindow.viewport.x,
event.clientY + this.boardWindow.viewport.y

View file

@ -70,9 +70,9 @@ class Mouse
this.position = new Vector(0, 0);
// Register the required event listeners
document.addEventListener("mouseup", handleMouseUp.bind(this));
document.addEventListener("mousedown", handleMouseDown.bind(this));
document.addEventListener("mousemove", handleMouseMove.bind(this));
document.addEventListener("mouseup", this.handleMouseUp.bind(this));
document.addEventListener("mousedown", this.handleMouseDown.bind(this));
document.addEventListener("mousemove", this.handleMouseMove.bind(this));
}
handleMouseUp(event)