added draw delay so it doesn't make my cpu scream
This commit is contained in:
@@ -1,11 +1,14 @@
|
||||
|
||||
import {noop} from './utils.js';
|
||||
|
||||
export default class Sketch {
|
||||
constructor(settings) {
|
||||
this.lastNow = null;
|
||||
|
||||
['getContext', 'onResize', 'render'].map(method => this[method] = this[method].bind(this));
|
||||
|
||||
this.draw = settings.draw || function() {}; // () => {};
|
||||
this.drawDelay = settings.drawDelay || 50;
|
||||
this.draw = settings.draw || noop;
|
||||
this.container = settings.element || document.body;
|
||||
|
||||
window.addEventListener('optimizedResize', this.onResize);
|
||||
@@ -34,7 +37,8 @@ export default class Sketch {
|
||||
this.draw(this.context);
|
||||
|
||||
this.lastNow = now;
|
||||
requestAnimationFrame(this.render);
|
||||
|
||||
setTimeout(() => {requestAnimationFrame(this.render)}, this.drawDelay);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user