Skip to content Skip to sidebar Skip to footer

Problem When Reloading An Animated Gif In Chrome - Part Ii

Continuing from Mark's suggestion here I am now using uiOutput and renderUI. The code below displays an animated gif ('anione'). When the 'Again' button is pressed it resets Chrome

Solution 1:

Can't you simply do

library(shiny)

# Define UI ----
ui <- fluidPage(
  uiOutput('anim_plot'),
  fluidRow(
    column(3,  
           actionButton("do_again", "Again")
    )
  )
)

# Define server logic ----
server <- function(input, output) {

  gif <- reactiveVal("ani.gif")

  observeEvent(input$do_again, {
    gif("ani2.gif")
  })

  output$anim_plot <- renderUI({
    img(src = gif(), width = "256")
  })

}

shinyApp(ui = ui, server = server)  

enter image description here

Post a Comment for "Problem When Reloading An Animated Gif In Chrome - Part Ii"