Learn R Programming

shinyLottie (version 1.0.0)

lottie_playback_controls: Control Playback of 'Lottie' Animations

Description

Control the playback of 'Lottie' animations within a 'shiny' application.

Usage

lottie_play(name = "all", session = shiny::getDefaultReactiveDomain())

lottie_pause(name = "all", session = shiny::getDefaultReactiveDomain())

lottie_stop(name = "all", session = shiny::getDefaultReactiveDomain())

Value

These functions are called for a side effect, and so there is no return value.

Arguments

name

A character string specifying the name of the 'Lottie' animation to control. The default of "all" will control all animations within the 'shiny' application.

session

The 'shiny' session object. Defaults to the current reactive domain.

Details

Each function sends a corresponding custom session message containing the function arguments:

  • Play: "lottie_js_play"

  • Pause: "lottie_js_pause"

  • Stop: "lottie_js_stop"

Examples

Run this code
if (FALSE) { # interactive()
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)
}

Run the code above in your browser using DataLab