Learn R Programming

shinyLottie (version 1.0.0)

lottie_navigate_frame: Navigate to a Specific Animation Frame

Description

Navigate to a specific frame or time and either stop or play the animation.

Usage

lottie_goToAndStop(
  value,
  isFrame = TRUE,
  name = "all",
  session = shiny::getDefaultReactiveDomain()
)

lottie_goToAndPlay( value, isFrame = TRUE, name = "all", session = shiny::getDefaultReactiveDomain() )

Value

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

Arguments

value

A numeric value specifying the frame or time to go to.

isFrame

A logical value indicating whether value is a frame number (TRUE) or time (FALSE).

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

lottie_goToAndStop moves the animation to a specific frame or time, then stops it. Sends a custom session message "lottie_js_goToAndStop" containing the function arguments.

lottie_goToAndPlay moves the animation to a specific frame or time, then continues playback. Sends a custom session message "lottie_js_goToAndPlay" 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"
  ),
  actionButton("goToAndStop", "Go To Frame 10 And Stop"),
  actionButton("goToAndPlay", "Go To Frame 10 And Play")
)

server <- function(input, output, session) {
  observeEvent(input$goToAndStop, {
    lottie_goToAndStop(value = 10, isFrame = TRUE, name = "my_animation")
  })

  observeEvent(input$goToAndPlay, {
    lottie_goToAndPlay(value = 10, isFrame = TRUE, name = "my_animation")
  })
}

shinyApp(ui, server)
}

Run the code above in your browser using DataLab