handle changes of board size
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user