Learn R Programming

shinyLottie (version 1.0.0)

lottie_setSpeed: Adjust 'Lottie' Animation Speed

Description

Adjust the speed of an existing 'Lottie' animation.

Usage

lottie_setSpeed(
  speed = 1,
  name = "all",
  session = shiny::getDefaultReactiveDomain()
)

Value

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

Arguments

speed

A numeric specifying the desired animation speed.

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

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

See Also

lottie_animation_methods for similar methods.

Examples

Run this code
if (FALSE) { # interactive()
library(shiny)
library(shinyLottie)

ui <- fluidPage(
  include_lottie(),
  lottie_animation(
    path = "shinyLottie/example.json",
    name = "my_animation"
  ),
  numericInput("speed", "Speed", value = 1),
  actionButton("updateSpeed", "Update Speed")
)

server <- function(input, output, session) {
  observeEvent(input$updateSpeed, {
    lottie_setSpeed(speed = input$speed, name = "my_animation")
  })
}

shinyApp(ui, server)
}

Run the code above in your browser using DataLab