JohnCoene / waiter

🕰️ Loading screens for Shiny
https://waiter.john-coene.com/
Other
499 stars 25 forks source link

Placement of the spinner wheel #77

Closed niv29 closed 3 years ago

niv29 commented 3 years ago

Feature to place the spinner wheel on top of the waiter screen would really help!

JohnCoene commented 3 years ago

This works on the Github development version.

library(shiny)
library(waiter)

ui <- fluidPage(
  use_waiter(), # include dependencies
  tags$style(
    ".waiter-overlay-content{
      position: absolute;
      top: 30px; /*30 pixels from the top*/
      left: 48%; /*48% from the left*/
    }"
  ),
  actionButton("showFull", "Show full screen"),
  actionButton("showPartial", "Show partial"),
  div(
    id = "hello", 
    style = "width:400px;height:500px;",
    h4("This could be a chart of whatever")
  )
)

server <- function(input, output, session){
  # partial
  w1 <- Waiter$new("hello")

  observeEvent(input$showPartial, {
    w1$show()
    Sys.sleep(4)
    w1$hide()
  })

  # full screen
  w2 <- Waiter$new()

  observeEvent(input$showFull, {
    w2$show()
    Sys.sleep(4)
    w2$hide()
  })
}

shinyApp(ui, server)

I'm not sure I should add it to the package: it would add more arguments, etc. where there are already many but it's worth mentioning in the documentation.

Let me know if this works.

JohnCoene commented 3 years ago

I'm going to go ahead and close before I forget. Feel free to reopen if you think this should be addressed differently.

niv29 commented 3 years ago

This works perfectly fine for partial screen. Thank you!!