lottie_setLoop {shinyLottie}R Documentation

Adjust 'Lottie' Animation Looping

Description

Adjust the looping behaviour of a 'Lottie' animation.

Usage

lottie_setLoop(flag, name = "all", session = shiny::getDefaultReactiveDomain())

Arguments

flag

Logical value specifying whether a 'Lottie' animation should loop (TRUE) or not (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

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

Value

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

See Also

lottie_animation_methods for similar methods.

Examples


library(shiny)
library(shinyLottie)

ui <- fluidPage(
  include_lottie(),
  lottie_animation(
    path = "shinyLottie/example.json",
    name = "my_animation"
  ),
  actionButton("play", "Play"),
  actionButton("loopOn", "Loop On"),
  actionButton("loopOff", "Loop Off")
)

server <- function(input, output, session) {
  observeEvent(input$play, {
    # Non-looped animations can not be resumed without first being stopped
    lottie_stop(name = "my_animation")
    lottie_play(name = "my_animation")
  })

  observeEvent(input$loopOn, {
    lottie_setLoop(flag = TRUE, name = "my_animation")
  })

  observeEvent(input$loopOff, {
    lottie_setLoop(flag = FALSE, name = "my_animation")
  })
}

shinyApp(ui, server)


[Package shinyLottie version 1.0.0 Index]