mirror of
https://github.com/sbrl/Nibriboard.git
synced 2018-01-10 21:33:49 +00:00
[client] Send a viewport update before requesting new chunks
This commit is contained in:
parent
d6b4b50588
commit
b34fb59575
2 changed files with 21 additions and 12 deletions
|
@ -320,6 +320,23 @@ class BoardWindow extends EventEmitter
|
|||
window.addEventListener("resize", this.matchWindowSize.bind(this));
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the current viewport to the server.
|
||||
*/
|
||||
sendViewport() {
|
||||
this.rippleLink.send({
|
||||
Event: "ViewportUpdate",
|
||||
NewViewport: {
|
||||
X: parseInt(this.viewport.x),
|
||||
Y: parseInt(this.viewport.y),
|
||||
Width: parseInt(this.viewport.width),
|
||||
Height: parseInt(this.viewport.height)
|
||||
}
|
||||
});
|
||||
|
||||
this.lastViewportUpdate = +new Date();
|
||||
}
|
||||
|
||||
/**
|
||||
* Handles events generated by pan-zoom, the package that handles the
|
||||
* dragging and zooming of the whiteboard.
|
||||
|
@ -345,17 +362,7 @@ class BoardWindow extends EventEmitter
|
|||
if(+new Date() - this.lastViewportUpdate < (1 / this.cursorSyncer.cursorUpdateFrequency) * 1000)
|
||||
return false;
|
||||
|
||||
this.rippleLink.send({
|
||||
Event: "ViewportUpdate",
|
||||
NewViewport: {
|
||||
X: parseInt(this.viewport.x),
|
||||
Y: parseInt(this.viewport.y),
|
||||
Width: parseInt(this.viewport.width),
|
||||
Height: parseInt(this.viewport.height)
|
||||
}
|
||||
});
|
||||
|
||||
this.lastViewportUpdate = +new Date();
|
||||
this.sendViewport();
|
||||
}).bind(this));
|
||||
}
|
||||
|
||||
|
|
|
@ -61,7 +61,9 @@ class ChunkCache
|
|||
}
|
||||
|
||||
if(missingChunks.length > 0) {
|
||||
// Asynchronously request them from the server
|
||||
// Make sure that the server knows our current viewport
|
||||
this.boardWindow.sendViewport();
|
||||
// Asynchronously request the missing chunks from the server
|
||||
this.boardWindow.rippleLink.send({
|
||||
"Event": "ChunkUpdateRequest",
|
||||
"ForgottenChunks": missingChunks
|
||||
|
|
Loading…
Reference in a new issue