From b9b1491862308d8be1e16fe6c8723d3dbde00db4 Mon Sep 17 00:00:00 2001 From: Cedrick Cooke Date: Thu, 20 Oct 2022 10:16:20 -0700 Subject: [PATCH] Fix flickering when resizing JS canvas (#191) --- element-view/src/jsMain/kotlin/ElementViewAdapter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/element-view/src/jsMain/kotlin/ElementViewAdapter.kt b/element-view/src/jsMain/kotlin/ElementViewAdapter.kt index 6bac07b2..ad3d5d03 100644 --- a/element-view/src/jsMain/kotlin/ElementViewAdapter.kt +++ b/element-view/src/jsMain/kotlin/ElementViewAdapter.kt @@ -80,11 +80,11 @@ public class ElementViewAdapter( if (state.width == 0 || state.height == 0) return@collectLatest dataSource.collect { data -> updater.update(state.root, state.width.toFloat(), state.height.toFloat(), data) - window.awaitAnimationFrame() val canvas = HtmlKanvas(state.view, state.scale) canvas.context.clearRect(0.0, 0.0, state.width.toDouble(), state.height.toDouble()) state.root.draw(canvas) canvas.context.resetTransform() + window.awaitAnimationFrame() } } }