Open kuzmenkov111 opened 5 years ago
Hello,
Thanks! Yes that's possible with shinyjs
, it depends if you use a custom target or not, if not you have to provide an Id, the particles div will have <id>-particles
as id. Check out these two examples :
library(shiny)
library(shinyparticles)
library(shinyjs)
ui <- fluidPage(
useShinyjs(),
particles(element_id = "myid"),
checkboxInput("toggle", "Show particles?", value = TRUE)
)
server <- function(input, output, session) {
observeEvent(input$toggle, {
if (input$toggle) {
show(id = "myid-particles")
} else {
hide(id = "myid-particles")
}
})
}
shinyApp(ui, server)
library(shiny)
library(shinyparticles)
library(shinyjs)
ui <- fluidPage(
useShinyjs(),
tags$div(
style = "background: #FFF; border: solid #112446; width: 100%; height: 400px; position: relative;",
tags$div(
id = "particles-target",
style = "position: absolute; top: 0; bottom: 0; right: 0; left: 0;"
)
),
particles(target_id = "particles-target"),
checkboxInput("toggle", "Show particles?", value = TRUE)
)
server <- function(input, output, session) {
observeEvent(input$toggle, {
if (input$toggle) {
show(id = "particles-target")
} else {
hide(id = "particles-target")
}
})
}
shinyApp(ui, server)
Victor
Thank you!! It's great!!! I haven't known about 'element_id' feature.
Hi!
Thanks for the implementation of a great feature! Is it possible to hide/show (remove/insert div with particles) animation from shiny page depend on some reactive value?