Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

How to not show loading spinner? #47

Open
analytichealth opened this issue Jan 21, 2024 · 3 comments
Open

How to not show loading spinner? #47

analytichealth opened this issue Jan 21, 2024 · 3 comments

Comments

@analytichealth
Copy link

analytichealth commented Jan 21, 2024

Hi again,

How can I prevent showing the loading spinner when using screenOutput?

I tried to use the standard class for the next button but this causes some strange behaviour. The next button changes class after a couple of seconds.

Thank you

Package version: 0.1.4
R verison 4.3.1

library(shiny)
library(shinyglide)

ui <- fluidPage(
  glide(
    loading_label = "Next ",
    loading_class = "btn btn-primary next-screen",
    screen(
      p("Do you want to see the next screen ?"),
      checkboxInput("check", "Yes, of course !", value = FALSE)
    ),
    screenOutput("check_screen"),
    screen(
      p("And this is the last screen")
    )
  )
)

server <- function(input, output, session) {
  output$check_screen <- renderUI({
    Sys.sleep(2)
    if(!input$check) return(NULL)
    screen(
      p("Here it is !")
    )
  })
  outputOptions(output, "check_screen", suspendWhenHidden = FALSE)
}

shinyApp(ui, server)
@juba
Copy link
Owner

juba commented Jan 28, 2024

Hi,

Maybe I don't understand what you're trying to achieve, but in your example if you don't define the loading_class argument I think the loading spinner is not shown ?

@analytichealth
Copy link
Author

Hi, I don't want the button to change at all when the checkboxInput becomes true. In my application when the loading spinner is shown the whole page moves to allow space for it.

If you don't apply a loading_class or loading_label the loading spinner is shown by default.

I managed to prevent the spinner by adding a loading_label (see example below) but the format of the next button still changes- it becomes a pale blue and then back to darker blue after the 2 second delay. It seems something in the javascript still happens when the checkboxInput becomes true.

library(shiny)
library(shinyglide)

ui <- fluidPage(
  glide(
    loading_label = paste("Next", shiny::icon("chevron-right", lib = "glyphicon")),
    # loading_class = "btn btn-primary next-screen",
    screen(
      p("Do you want to see the next screen ?"),
      checkboxInput("check", "Yes, of course !", value = FALSE)
    ),
    screenOutput("check_screen"),
    screen(
      p("And this is the last screen")
    )
  )
)

server <- function(input, output, session) {
  output$check_screen <- renderUI({
    Sys.sleep(2)
    if (!input$check) return(NULL)
    screen(
      p("Here it is !")
    )
  })
  outputOptions(output, "check_screen", suspendWhenHidden = FALSE)
}

shinyApp(ui, server)

@juba
Copy link
Owner

juba commented Feb 4, 2024

I think the pale blue / dark blue transition is not directly due to shinyglide but to shiny, It is the same visual effect as for any output update. If you want to disable it I think you would have to tweak the CSS for this element.

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

No branches or pull requests

2 participants