handle changes of board size

This commit is contained in:
Gavin McDonald
2018-09-12 22:45:19 -04:00
parent bf85712363
commit 85fbc28cf4
3 changed files with 44 additions and 13 deletions

View File

@@ -6,6 +6,7 @@ export default class Sketch {
[
'getContext',
'getSize',
'onResize',
'render',
].map(method => this[method] = this[method].bind(this));
@@ -32,6 +33,13 @@ export default class Sketch {
return this.context;
}
getSize () {
return {
canvasWidth: this.container.offsetWidth,
canvasHeight: this.container.offsetHeight,
}
}
onResize (event) {
const width = this.container.offsetWidth;
const height = this.container.offsetHeight;