mirror of
https://github.com/sbrl/Nibriboard.git
synced 2018-01-10 21:33:49 +00:00
[client] Make the pencil listen to mouse events on the canvas, not the document
This commit is contained in:
parent
aa0852a3b2
commit
ec5f7e0bd9
2 changed files with 5 additions and 5 deletions
|
@ -258,7 +258,7 @@ class BoardWindow extends EventEmitter
|
||||||
this.sidebar.style.borderTopColor = this.Colour;
|
this.sidebar.style.borderTopColor = this.Colour;
|
||||||
|
|
||||||
// The pencil that draws the lines
|
// The pencil that draws the lines
|
||||||
this.pencil = new Pencil(this.rippleLink, this);
|
this.pencil = new Pencil(this.rippleLink, this, this.canvas);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -13,7 +13,7 @@ class Pencil
|
||||||
* @param {RippleLink} inRippleLink The connection to the nibri server.
|
* @param {RippleLink} inRippleLink The connection to the nibri server.
|
||||||
* @return {Pencil} A new Pencil class instance.
|
* @return {Pencil} A new Pencil class instance.
|
||||||
*/
|
*/
|
||||||
constructor(inRippleLink, inBoardWindow)
|
constructor(inRippleLink, inBoardWindow, canvas)
|
||||||
{
|
{
|
||||||
this.boardWindow = inBoardWindow;
|
this.boardWindow = inBoardWindow;
|
||||||
|
|
||||||
|
@ -47,9 +47,9 @@ class Pencil
|
||||||
// The time of the last push of the line to the server.
|
// The time of the last push of the line to the server.
|
||||||
this.lastServerPush = 0;
|
this.lastServerPush = 0;
|
||||||
|
|
||||||
document.addEventListener("mouseDown", this.handleMouseDown.bind(this));
|
canvas.addEventListener("mouseDown", this.handleMouseDown.bind(this));
|
||||||
document.addEventListener("mouseMove", this.handleMouseMove.bind(this));
|
canvas.addEventListener("mouseMove", this.handleMouseMove.bind(this));
|
||||||
document.addEventListener("mouseUp", this.handleMouseUp.bind(this));
|
canvas.addEventListener("mouseUp", this.handleMouseUp.bind(this));
|
||||||
}
|
}
|
||||||
|
|
||||||
handleMouseMove(event) {
|
handleMouseMove(event) {
|
||||||
|
|
Loading…
Reference in a new issue