RinteRface / shinybulma

🌐 Bulma.io for Shiny
https://rinterface.github.io/shinybulma/
Other
111 stars 15 forks source link

bulmaPageloader is removed on startup #37

Open thothal opened 3 years ago

thothal commented 3 years ago

Consider a use case, where I want to show a pageloader until the shiny app first becomes idle. I would use the following code:

library(shiny)
library(shinybulma)

js <- HTML("$(document).one('shiny:idle', () => $('.pageloader').removeClass('is-active'))")

ui <- bulmaPage(
   tags$head(tags$script(js)), 
   div(class = "pageloader is-active"), 
   uiOutput("slow_me")
   )

server <- function(input, output, session) {
   output$slow_me <- renderUI({
      Sys.sleep(3)
      p("Done")
   })
}

shinyApp(ui, server)

However, this does not work, because of this: https://github.com/RinteRface/shinybulma/blob/93855e2820cb12d5b2e9f4cb1514f2ec1e15a2d4/inst/js-0.7.2/bulma-pageloader-js.js#L5-L8

Which can be easily verified by not loading bulma-pageloader-js.js

no_dep <- htmltools::htmlDependency(
      name = "js", 
      version = "0.7.3",
      src = c(file = system.file("js-0.7.2", package = "shinybulma")),
      script = setdiff(list.files(system.file("js-0.7.2", package = "shinybulma")),
                       "bulma-pageloader-js.js")
   )
ui2 <- tagAppendChild(ui, no_deps)
shinyApp(ui2, server)

Hence, I would drop bulma-pageloader-js.js and let the user define when to load and unload the pageloader