Selialises an anime_timeline() object to JSON and wraps it together with
an SVG payload in an htmlwidget.
Arguments
- timeline
An
anime_timelineobject produced byanime_timeline().- svg
Character. Raw SVG markup to embed in the widget. If
NULL, an empty string is used (the timeline will animate against existing DOM content – advanced use only).- width
Fixed width for widget (in css units). The default is
NULL, which results in intelligent automatic sizing based on the widget's container.- height
Fixed height for widget (in css units). The default is
NULL, which results in intelligent automatic sizing based on the widget's container.- elementId
Use an explicit element ID for the widget (rather than an automatically generated one). Useful if you have other JavaScript that needs to explicitly discover and interact with a specific widget instance.
Examples
tl <- anime_timeline(duration = 800) |>
anime_add(
selector = anime_target_class("dot"),
props = list(opacity = anime_from_to(0, 1))
)
svg <- '<svg viewBox="0 0 100 100"><circle class="dot" cx="50" cy="50" r="10"/></svg>'
if (interactive()) {
anime_render(tl, svg)
}