lottie_playback_controls | R Documentation |
Control the playback of 'Lottie' animations within a 'shiny' application.
lottie_play(name = "all", session = shiny::getDefaultReactiveDomain())
lottie_pause(name = "all", session = shiny::getDefaultReactiveDomain())
lottie_stop(name = "all", session = shiny::getDefaultReactiveDomain())
name |
A character string specifying the name of the 'Lottie' animation to control.
The default of " |
session |
The 'shiny' session object. Defaults to the current reactive domain. |
Each function sends a corresponding custom session message containing the function arguments:
Play: "lottie_js_play
"
Pause: "lottie_js_pause
"
Stop: "lottie_js_stop
"
These functions are called for a side effect, and so there is no return value.
library(shiny)
library(shinyLottie)
ui <- fluidPage(
include_lottie(),
lottie_animation(
path = "shinyLottie/example.json",
name = "my_animation"
),
actionButton("play", "Play Animation"),
actionButton("pause", "Pause Animation"),
actionButton("stop", "Stop Animation")
)
server <- function(input, output, session) {
observeEvent(input$play, {
lottie_play(name = "my_animation")
})
observeEvent(input$pause, {
lottie_pause(name = "my_animation")
})
observeEvent(input$stop, {
lottie_stop(name = "my_animation")
})
}
shinyApp(ui, server)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.