if (FALSE) { # interactive()
library(shiny)
library(shinyLottie)
ui <- fluidPage(
include_lottie(),
lottie_animation(
path = "shinyLottie/example.json",
name = "my_animation",
loop = FALSE,
speed = 0.5 # Slowed to make effects clearer
),
actionButton("playSegments1", "Play Frames 1 - 10"),
# Will not work if animation has less than 40 frames
actionButton("playSegments2", "Play Frames 1 - 10 and 30 - 40")
)
server <- function(input, output, session) {
observeEvent(input$playSegments1, {
lottie_playSegments(segments = c(1, 10), forceFlag = TRUE,
name = "my_animation")
})
observeEvent(input$playSegments2, {
lottie_playSegments(segments = list(c(1, 10), c(30, 40)),
forceFlag = TRUE, name = "my_animation")
})
}
shinyApp(ui, server)
}
Run the code above in your browser using DataLab