Closed aryx closed 4 years ago
You can use Vdom.elt
to build an arbitrary element.
Canvas is inherently an "impure" component that does not mix natively well with the vdom approach. SVG would work better if this is an option for you. Otherwise, you could use a "Custom" element, and either represent the figure state as part of its vdom representation, or manipulate it in a more imperative style (loosing the benefits of vdom).
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/.
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?
Subscriptions can be emulated with custom elements (see #32).
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.
I've created a separate issue for the animation frame.
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