From 14fe561c424c2db0fc3ed996be05107886517c01 Mon Sep 17 00:00:00 2001 From: cha0s Date: Thu, 28 Mar 2019 12:45:22 -0500 Subject: [PATCH] refactor: animation frame --- client/index.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client/index.js b/client/index.js index 57f7f91..f669309 100644 --- a/client/index.js +++ b/client/index.js @@ -5,6 +5,7 @@ import {Container, Renderer} from '@avocado/graphics'; import {World} from '@avocado/physics/matter/world'; import {StateSynchronizer} from '@avocado/state'; import {Room, RoomView} from '@avocado/topdown'; +import {clearAnimation, setAnimation} from '@avocado/timing'; const renderer = new Renderer([640, 360]); const stage = new Container(); @@ -94,13 +95,14 @@ function render() { renderer.render(stage); dirty = false; } -const renderHandle = setInterval(render, 1000 / 60); +const renderHandle = setAnimation(render); // Hot reloading. if (module.hot) { module.hot.accept((error) => { console.error(error); }); module.hot.dispose(() => { + clearAnimation(renderHandle); room.destroy(); appNode.removeChild(renderer.element); stage.destroy();