if (interactive()) {
library(shiny)
library(shinybusy)
ui <- fluidPage(
tags$h1("Modal with spinner"),
actionButton("sleep1", "Launch a long calculation"),
actionButton("sleep2", "And another one")
)
server <- function(input, output, session) {
observeEvent(input$sleep1, {
show_modal_gif(
src = "https://jeroen.github.io/images/banana.gif"
)
Sys.sleep(5)
remove_modal_gif()
})
observeEvent(input$sleep2, {
show_modal_gif(
src = "https://jeroen.github.io/images/banana.gif",
width = "300px", height = "300px",
modal_size = "m",
text = "Please wait..."
)
Sys.sleep(5)
remove_modal_gif()
})
}
shinyApp(ui, server)
}
Run the code above in your browser using DataLab