give my poor fan a break

This commit is contained in:
Gavin McDonald
2019-01-30 22:11:55 -05:00
parent cdd64ab1cc
commit 818bc3d433
3 changed files with 42 additions and 24 deletions

View File

@@ -13,7 +13,6 @@ export default class Sketch {
this.draw = settings.draw || noop;
this.resize = settings.resize || noop;
this.drawDelay = settings.drawDelay;
this.container = settings.element || document.body;
window.addEventListener('resize', this.onResize);
@@ -69,11 +68,11 @@ export default class Sketch {
this.context.now = now;
this.context.lastNow = this.lastNow;
this.draw(this.context);
const drawDelay = this.draw(this.context);
this.lastNow = now;
if (this.drawDelay) setTimeout(() => requestAnimationFrame(this.render), this.drawDelay);
if (drawDelay) setTimeout(() => requestAnimationFrame(this.render), drawDelay);
else requestAnimationFrame(this.render);
}
}