Description Usage Arguments Note See Also Examples
You can use delay
if you want to wait a specific amount of time before
running code. This function can be used in combination with other shinyjs
functions, such as hiding or resetting an element in a few seconds, but it
can also be used with any code as long as it's used inside a Shiny app.
1 | delay(ms, expr)
|
ms |
The number of milliseconds to wait (1000 milliseconds = 1 second) before running the expression. |
expr |
The R expression to run after the specified number of milliseconds has elapsed. |
shinyjs
must be initialized with a call to useShinyjs()
in the app's ui.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | if (interactive()) {
library(shiny)
shinyApp(
ui = fluidPage(
useShinyjs(),
p(id = "text", "This text will disappear after 3 seconds"),
actionButton("close", "Close the app in half a second")
),
server = function(input, output) {
delay(3000, hide("text"))
observeEvent(input$close, {
delay(500, stopApp())
})
}
)
}
|
Attaching package: 'shinyjs'
The following objects are masked from 'package:methods':
removeClass, show
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.