From 823f405880adce5879b724e10b903ae24cb8a8a4 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 16 Apr 2022 12:36:14 +0100 Subject: [PATCH] dice js: Break out die_request_animation We're going to want to re-request animiation in the frame renderer, obviously. Signed-off-by: Ian Jackson --- templates/script.ts | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/templates/script.ts b/templates/script.ts index 464387e0..a69bbab1 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -2268,10 +2268,14 @@ type DieSpecialRendering = SpecialRendering & { special_renderings['Die'] = function(piece: PieceId, p: PieceInfo, s: DieSpecialRendering) { s.stop = die_rendering_stop as any; + die_request_animation(piece, p, s); +} as any; +function die_request_animation(piece: PieceId, p: PieceInfo, + s: DieSpecialRendering) { s.anim_id = window.requestAnimationFrame( function(ts) { die_render_frame(piece, p, s, ts) } ); -} as any; +} function die_render_frame(piece: PieceId, p: PieceInfo, s: DieSpecialRendering, ts: DOMHighResTimeStamp) { s.anim_id = null; -- 2.30.2