Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Kino.Frame for animations #49

Merged
merged 3 commits into from
Nov 8, 2021
Merged

Add Kino.Frame for animations #49

merged 3 commits into from
Nov 8, 2021

Conversation

jonatanklosko
Copy link
Member

@jonatanklosko jonatanklosko commented Nov 8, 2021

Closes #48. For the Livebook counterpart see livebook-dev/livebook#688.

This introduces a new dynamic output that wraps a single static output, which can be replaced at any time. Additionally, we now have Kino.animate wrapping the most common use case.

kino_frame.mp4

Sidenote: Kino.animate is how to flip book in Livebook

lib/kino.ex Outdated Show resolved Hide resolved
@josevalim
Copy link
Contributor

I love the name and the abstraction!

Some concerns:

  1. Is it too much to have both the public module and Kino.animate? Shall we @moduledoc false this one? Or do we need to keep it public because the result of Kino.animate is public?
  2. Kino.render does not return an output. Kino.VegaLite.periodically only returns ok. The fact animate does is a bit inconsistent?
  3. Should we rename Kino.VegaLite.periodically to Kino.VegaLite.animate for consistency?

@jonatanklosko
Copy link
Member Author

jonatanklosko commented Nov 8, 2021

@josevalim

  1. We still want Kino.Frame to be public, because someone may use it explicitly, specifically the Kino.Frame.render function. This can be useful if the rendering is not periodical, but rather based on some event, just to give an example, someone may re-render output from an Axon callback.
  2. Ah, initially I thought we want to return the widget to render it, but you're absolutely right, we should call Kino.render from Kino.animate, so it works anywhere in the cell.
  3. For the widgets, periodically is actually more accurate. The callback we pass to periodically doesn't return any new data to animate, it needs to be done using Kino.VegaLite.{push,push_many} or Kino.Frame.render.

@jonatanklosko jonatanklosko merged commit 1e8a40b into main Nov 8, 2021
@jonatanklosko jonatanklosko deleted the jk-frame branch November 8, 2021 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Dynamic Image widget
3 participants