Closed mgarnault closed 2 years ago
Mea culpa,
I had not tried to put directly a show_modal_spinner() after a show_modal_spinner(), which gives the result I was looking for...
The solution :
show_modal_spinner(spin = "orbit", text = "First part of computation", color = "#08298A")
Sys.sleep(1) # some computation
show_modal_spinner(spin = "orbit", text = "Second part of computation", color = "#08298A")
Sys.sleep(1) # some other computation
remove_modal_spinner()
This non-problem is therefore closed.
After some trials I have discovered a bug caused by calling successively show_modal_spinner() without using remove_modal_spinner() inbetween. Indeed, when the page content requires an Y-scrollbar due to overflowing vertical content, the use of successive show_modal_spinner() leads to an horizontal shrinkage of the page content. In particular, at each computation phase (that displays the spinners), the page content shrinks by one Y-scrollbar width.
Here is a reproducible example using shinydasboard :
library(shiny)
library(shinydashboard)
library(shinybusy)
ui = dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(actionButton("go", "Run computation"),
box(height = 5000,
title = "A very high box which implies the presence of a Y-scrollbar"))
)
server = function(input, output, session){
observeEvent(input$go,{
show_modal_spinner(text = "Computation part1")
Sys.sleep(.25)
# remove_modal_spinner()
show_modal_spinner(text = "Computation part2")
Sys.sleep(.25)
# remove_modal_spinner()
show_modal_spinner(text = "Computation part3")
Sys.sleep(.25)
# remove_modal_spinner()
show_modal_spinner(text = "Computation part4")
Sys.sleep(.25)
remove_modal_spinner()
})
}
shinyApp(ui, server)
You will see (I hope) the horizontal shrinkage with this version of code. If you uncomment the "remove_modal_spinner()" functions, you will see that the shrinkage vanishes ! Therefore, I am still looking for a working and stable solution to update spinner texts without using remove_modal_spinner(), as it creates a non-fluid experience for the user as I described in my original post (quick on and off of the spinner box which leads to kind of "light flashes" as the background is sucessively shaded and unshaded). Can you help me on that ?
Thank you in advance !
Indeed that's ennuyeux.
If you re-install from GitHub, there's a new function update_modal_spinner()
, so you can do in your server:
observeEvent(input$sleep1, {
show_modal_spinner(spin = "orbit", text = "First part of computation", color = "#08298A")
Sys.sleep(2) # some computation
update_modal_spinner("Second part of computation")
Sys.sleep(3) # some other computation
remove_modal_spinner()
})
Victor
Great, this works flawlessly ! Thanks a lot for your responsiveness.
Maxime
Hi,
I am wondering if it is possible to update show_modal_spinner() displayed text without using remove_modal_spinner() and then re-define a new show_modal_spinner() (with a different text within) ? Even if the combination of remove_modal_spinner() and show_modal_spinner() works, it is not very fluid for the user. Indeed, we can see the quick on and off of the spinner box (in addition, it creates some "light flashes" as the spinner box background is sucessively shaded and unshaded).
Here is what I am currently using :
Here is what I'm looking for :
Thanks !