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

[client] Send viewport updates to the server.

This commit is contained in:
Starbeamrainbowlabs 2017-07-29 20:42:07 +01:00
parent b673719b78
commit ac0d947e31

View file

@ -55,6 +55,7 @@ class BoardWindow extends EventEmitter
this.Colour = "rgba(255, 255, 255, 0.3)"; this.Colour = "rgba(255, 255, 255, 0.3)";
// The current state of the viewport. // The current state of the viewport.
this.lastViewportUpdate = +new Date();
this.viewport = { this.viewport = {
// The x coordinate of the viewport. // The x coordinate of the viewport.
x: 0, x: 0,
@ -337,6 +338,25 @@ class BoardWindow extends EventEmitter
this.viewport.y -= event.dy * 1/this.viewport.zoomLevel; this.viewport.y -= event.dy * 1/this.viewport.zoomLevel;
this.viewport.zoomLevel += event.dz / 1000; this.viewport.zoomLevel += event.dz / 1000;
this.viewport.zoomLevel = clamp(this.viewport.zoomLevel, 0.1, 10000); this.viewport.zoomLevel = clamp(this.viewport.zoomLevel, 0.1, 10000);
// Update the server on the new size of our viewport
setTimeout((function() {
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();
}).bind(this));
} }
/** /**