diff --git a/examples/web-skia/src/jsMain/kotlin/com/sample/Main.kt b/examples/web-skia/src/jsMain/kotlin/com/sample/Main.kt index 8719276f90..0cf36a01a1 100644 --- a/examples/web-skia/src/jsMain/kotlin/com/sample/Main.kt +++ b/examples/web-skia/src/jsMain/kotlin/com/sample/Main.kt @@ -8,6 +8,7 @@ import androidx.compose.animation.core.tween import androidx.compose.foundation.Canvas import androidx.compose.foundation.layout.fillMaxSize import androidx.compose.foundation.layout.size +import androidx.compose.material.Text import androidx.compose.runtime.Composable import androidx.compose.runtime.LaunchedEffect import androidx.compose.runtime.remember @@ -362,6 +363,8 @@ fun SomeCanvas() { // property("margin", "0 auto") } }) { + Text("xxxx") + skiko { val radius = remember { Animatable(10f) } LaunchedEffect(radius) { @@ -374,6 +377,8 @@ fun SomeCanvas() { ) } + Text(text = "Xxx") + Canvas( modifier = Modifier .size(400.dp) @@ -460,9 +465,7 @@ fun App() { } fun main() { - onWasmReady { - renderComposable(rootElementId = "root") { - App() - } + renderComposable(rootElementId = "root") { + App() } } diff --git a/web/core/src/jsMain/kotlin/org/jetbrains/compose/skiko/skiko.kt b/web/core/src/jsMain/kotlin/org/jetbrains/compose/skiko/skiko.kt index ebd8088b29..67e21f7b73 100644 --- a/web/core/src/jsMain/kotlin/org/jetbrains/compose/skiko/skiko.kt +++ b/web/core/src/jsMain/kotlin/org/jetbrains/compose/skiko/skiko.kt @@ -8,12 +8,15 @@ package org.jetbrains.compose.web.skiko import androidx.compose.runtime.Composable import androidx.compose.ui.window.ComposeCanvas import org.jetbrains.compose.web.dom.ElementScope +import org.jetbrains.skiko.wasm.onWasmReady import org.w3c.dom.HTMLCanvasElement @Composable fun ElementScope.skiko(block: @Composable () -> Unit) { DomSideEffect { canvas -> - val skikoCanvas = ComposeCanvas(canvas) - skikoCanvas.setContent(block) + onWasmReady { + val skikoCanvas = ComposeCanvas(canvas) + skikoCanvas.setContent(block) + } } } \ No newline at end of file