Learn R Programming

shinyLottie (version 1.0.0)

lottie_getProperty: Get a Property of a 'Lottie' Animation

Description

Get a property from a specific 'Lottie' animation or all 'Lottie' animations.

Usage

lottie_getProperty(
  property,
  name = "all",
  session = shiny::getDefaultReactiveDomain()
)

Value

The return value(s) can be retrieved from within a reactive context by accessing the input object of the 'shiny' session, where the value has been assigned as the property name. For example, if accessing the playCount property, the return value can be retrieved via input$playCount.

If name = "all" has been specified, then the return object will be a list, with named elements corresponding to the animation names.

Arguments

property

A character string specifying the name of the property to retrieve.

name

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

session

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

Details

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

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("getProperty", "Update Play Count"),
  textOutput("playCountOutput")
)

server <- function(input, output, session) {
  observeEvent(input$getProperty, {
    lottie_getProperty(name = "my_animation", property = "playCount")
  })

  observe({
    req(input$playCount)
    output$playCountOutput <- renderText({
      paste("Play Count:", input$playCount)
    })
  })
}

 shinyApp(ui, server)
}

Run the code above in your browser using DataLab