Skip to content

Commit ee78ad7

Browse files
Fixed viewbox
1 parent 1e1f1f6 commit ee78ad7

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

utils/Canvas.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ import ToolHandler from "../handlers/Tool.js";
66
export default class {
77
constructor(view) {
88
this.view = view;
9-
let computedStyle = getComputedStyle(this.view);
9+
let boundingRect = view.getBoundingClientRect();
1010
this.view.style.setProperty("stroke-linecap", "round");
1111
this.view.style.setProperty("stroke-linejoin", "round");
12-
this.view.setAttribute("viewBox", `0 0 ${parseInt(computedStyle.width)} ${parseInt(computedStyle.height)}`);
12+
this.view.setAttribute("viewBox", `0 0 ${boundingRect.width} ${boundingRect.height}`);
1313

1414
this.layers.create();
1515

@@ -19,8 +19,7 @@ export default class {
1919
this.mouse.on("up", this.clip.bind(this));
2020

2121
window.addEventListener("resize", this.resize.bind(this));
22-
23-
document.addEventListener("keydown", this.keyDown.bind(this));
22+
document.addEventListener("keydown", this.keydown.bind(this));
2423
}
2524
zoom = 1;
2625
zoomIncrementValue = 0.5;
@@ -331,7 +330,7 @@ export default class {
331330
}
332331
}
333332

334-
keyDown(event) {
333+
keydown(event) {
335334
event.preventDefault();
336335
event.stopPropagation();
337336
switch(event.key) {

0 commit comments

Comments
 (0)