LexiFi / ocaml-vdom

Elm architecture and (V)DOM for OCaml
MIT License
197 stars 13 forks source link

More complex elements in Vdom #35

Closed aryx closed 4 years ago

aryx commented 4 years ago

I can currently see only div/input/text as HTML elements in Vdom.mli. What about h1/h2/...? How can I construct such vdom elements? What about canvas? I would like to create a reactive app where the model contains the description of a figure (which can be modified) and I would like a view using a canvas to render its content. How can I build such a reactive app with Vdom? I can see bindings to the Canvas API in JS_browser.mli, but those canvas elements are not available in Vdom.mli

alainfrisch commented 4 years ago
aryx commented 4 years ago

Thx. Would be great to have by default a few common HTML elements in Vdom.mli and a few more examples using canvas or SVG in examples/.

aryx commented 4 years ago

I am also curious how I could implement a game using ocaml-vdom. For example in ELM in this pong example https://github.com/ukikagi/making-pong-in-elm/blob/master/src/main.elm they use , Browser.Events.onAnimationFrameDelta Tick which I could not find an equivalent in ocaml-vdom. In ELM they also have this concept of subscriptions, for example Time.every 10 Tick can generate Tick events every 10 ms. Is there an equivalent in ocaml-vdom?

alainfrisch commented 4 years ago

Subscriptions can be emulated with custom elements (see #32).

aryx commented 4 years ago

I had a look at #32 but still fail to see how to generate a `Tick msg after each animation frame. I can see from the tipply.ml example how to subscribe to browser events like resize, but the animation frame is not in the list of event. Moreover it looks like vdom_blit is using request_animation_frame already, but I need to get a Tick from those.

aryx commented 4 years ago

I've created a separate issue for the animation frame.