Skip to contents

Call a method for a specific 'Lottie' animation or all 'Lottie' animations.

Usage

lottie_callMethod(
  name = "all",
  method,
  argument = "",
  session = shiny::getDefaultReactiveDomain()
)

Arguments

name

A character string specifying the name of the 'Lottie' animation to query. The default of "all" will retrieve the specified property from all 'Lottie' animations within the 'shiny' application.

method

A character string specifying the name of the method to call.

argument

A character string specifying any optional arguments to pass to the method.

session

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

Value

This function is called for a side effect, and so there is no return value.

Details

Sends a custom session message "lottie_js_callMethod" containing the function arguments.

Examples

if (FALSE) { # interactive()
library(shiny)
library(shinyLottie)

ui <- fluidPage(
  include_lottie(),
  lottie_animation(
    path = "shinyLottie/example.json",
    name = "my_animation"
  ),
  actionButton("callMethod", "Call Method (Reverse Direction)")
)

server <- function(input, output, session) {
  observeEvent(input$callMethod, {
    lottie_callMethod(name = "my_animation", method = "setDirection", argument = "-1")
  })
}
shinyApp(ui, server)
}