Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

bulmaPageloader is removed on startup #37

Open
thothal opened this issue Jun 3, 2021 · 0 comments
Open

bulmaPageloader is removed on startup #37

thothal opened this issue Jun 3, 2021 · 0 comments

Comments

@thothal
Copy link

thothal commented Jun 3, 2021

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:

$(window).on('load', function () {
$(".pageloader").removeClass('is-active');
$(".pageloader").css('display', 'none');
});

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

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant