LexiFi / ocaml-vdom

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

We can't generate a `Tick event on each animation frame #37

Open aryx opened 3 years ago

aryx commented 3 years ago

For context, I try to port the elm-playground library to OCaml by using ocaml-vdom.

In elm, one can subscribe to the onAnimationFrame Javascript event to generate a Tick (or `Tick) message that can be used in the update function to provide animations.

I was able to find the onmousemove event in vdom (that I attach as an attribute to the toplevel div), but nothing on animation_frame. @alainfrisch mention I could use custom event for that, but onAnimationFrame is not listed as one of the possible Javascript event.

aryx commented 3 years ago

Any help? Is this project dead? Should I switch to another OCaml library (e.g., Brr by daniel buenzli?)

alainfrisch commented 3 years ago

The project is actively used, and we are happy to address bug reports, discuss feature wishes or review PRs.

Your question probably requires doing some manual DOM-based code with CustomElements, using Window.requestAnimationFrame. Feel free to experiment, and if you find a solution, to report if something needs to be added to ocaml-vdom to make the task easier.

aryx commented 3 years ago

Is there code I should imitate to do that? I'm a JS/Browser noob.

aryx commented 10 months ago

Is this issue fixed in the vdom 0.3 version? https://discuss.ocaml.org/t/ann-vdom-0-3-functional-ui-applications-now-with-custom-event-handlers/13298