mirror of
https://github.com/sbrl/Nibriboard.git
synced 2018-01-10 21:33:49 +00:00
Fix chunk loading when zoomed in.
This commit is contained in:
parent
653df90674
commit
dc795f6d00
4 changed files with 10 additions and 5 deletions
|
@ -62,11 +62,11 @@ class BoardWindow extends EventEmitter
|
||||||
y: 0,
|
y: 0,
|
||||||
// The width of the viewport
|
// The width of the viewport
|
||||||
get width() {
|
get width() {
|
||||||
return canvas.width * 1/this.zoomLevel
|
return canvas.width * (1/this.zoomLevel)
|
||||||
},
|
},
|
||||||
// The height of the viewport
|
// The height of the viewport
|
||||||
get height() {
|
get height() {
|
||||||
return canvas.height * 1/this.zoomLevel
|
return canvas.height * (1/this.zoomLevel)
|
||||||
},
|
},
|
||||||
// The zoom level of the viewport. 1 = normal.
|
// The zoom level of the viewport. 1 = normal.
|
||||||
zoomLevel: 1,
|
zoomLevel: 1,
|
||||||
|
|
|
@ -50,8 +50,8 @@ class ChunkCache
|
||||||
let chunkArea = new Rectangle(
|
let chunkArea = new Rectangle(
|
||||||
Math.floor(visibleArea.x / chunkSize) * chunkSize,
|
Math.floor(visibleArea.x / chunkSize) * chunkSize,
|
||||||
Math.floor(visibleArea.y / chunkSize) * chunkSize,
|
Math.floor(visibleArea.y / chunkSize) * chunkSize,
|
||||||
(Math.floor((visibleArea.x + (visibleArea.width / visibleArea.zoomLevel)) / chunkSize) * chunkSize),
|
(Math.ceil((visibleArea.x + (visibleArea.width)) / chunkSize) * chunkSize),
|
||||||
(Math.floor((visibleArea.y + (visibleArea.height / visibleArea.zoomLevel)) / chunkSize) * chunkSize)
|
(Math.ceil((visibleArea.y + (visibleArea.height)) / chunkSize) * chunkSize)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -126,6 +126,11 @@ hr
|
||||||
z-index: 5000;
|
z-index: 5000;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.debug-value
|
||||||
|
{
|
||||||
|
font-family: monospace; /* todo: use custom fonts! :D */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
.fps
|
.fps
|
||||||
{
|
{
|
||||||
|
|
|
@ -44,7 +44,7 @@
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
<aside id="debuginfo">
|
<aside id="debuginfo">
|
||||||
<label>Viewport:</label> <output id="debug-viewport">?</output>
|
<label>Viewport:</label> <output id="debug-viewport" class="debug-value">?</output>
|
||||||
|
|
||||||
</aside>
|
</aside>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue