https://kotlinlang.org logo
#compose-web
Title
# compose-web
n

Nikky

04/03/2022, 4:29 PM
compose web draws into a canvas.. what javascript hooks would i need to adjust the canvas to the browser window size each time it gets resized ? i tried
Copy code
function resize_canvas(){
    canvas = document.getElementById("ComposeTarget");
    canvas.width  = window.innerWidth;
    canvas.height = window.innerHeight;
}
with
Copy code
<body onresize="resize_canvas()">
and.. although that resizes the canvas.. it stops rendering
h

hfhbd

04/04/2022, 3:03 PM
what do you mean by
compose web draws into a canvas
? It does not by default with the current dom api.
👍🏻 1
n

Nikky

04/04/2022, 4:34 PM
at least the example i worked from used a canvas .. and when i try to use
renderComposable(rootElementId = "root")
it seems to throw for me.. so i used the canvas for a while i guess i will try to make DOm renderer work
h

hfhbd

04/05/2022, 12:08 AM
Currently, compose does not support canvas and you have to use it by yourself. 🤔
n

Nikky

04/05/2022, 4:24 PM
Wonder where i got the sample from that uses skia to render composable on a canvas then
h

hfhbd

04/05/2022, 4:25 PM
The MPP falling balls example uses the experimental canvas api. Currently, the Dom api is published and "stable". At the start, JB tried to convert the compose foundation to the web too, by using the html Dom api. This was called widget api and is deprecated. the new replacement is not available at the moment.
n

Nikky

04/05/2022, 4:27 PM
Yeah i am using that.. But the dom api seems broken in the alphas
Making a desktop+web client seems hard right now with components that work on one but not the other..
h

hfhbd

04/05/2022, 4:46 PM
Yeah, at the moment you can share your logic, but must use different UI apis
23 Views