Display Too Long

I have a load counter in brilliant state, which is implemented similarly t its answer :

conditionalPanel(condition="$('html').hasClass('shiny-busy')",
                 tags$div("Loading...",id="loadmessage")
)



runApp(list(
  ui = pageWithSidebar(
      headerPanel("Test"),
         sidebarPanel(
           tags$head(tags$style(type="text/css", "
             #loadmessage {
               position: fixed;
               top: 0px;
               left: 0px;
               width: 100%;
               padding: 5px 0px 5px 0px;
               text-align: center;
               font-weight: bold;
               font-size: 100%;
               color: #000000;
               background-color: #CCFF66;
               z-index: 105;
             }
          ")),
           numericInput('n', 'Number of obs', 100),
           conditionalPanel(condition="$('html').hasClass('shiny-busy')",
                            tags$div("Loading...",id="loadmessage"))
         ),
         mainPanel(plotOutput('plot'))
  ),
  server = function(input, output) {
    output$plot <- renderPlot({ Sys.sleep(2); hist(runif(input$n)) })
  }
))

The problem I am facing is that the bootloader appears all the time, even when the gloss is busy for only a split second. This causes the application to constantly flash and exit. Is there a way to basically set the delay on the conditional panel so that the counter appears only after the page is busy for a second?

+4
source share
3 answers

I ran into this package: shinysky. ( here is github )

busyIndicator, , , busyIndicator(wait=1000) ui.R.

, busyIndicator R, js, setTimeout.

+2

, , "" "". ( , ).

debounce. , , debug debad.

, , , , , :

// flag of busyness
var isBusy = false;

// ...
// operation in progress, start the counting
isBusy = true;
_.debounce(showSpinner, 1000, {
   'trailing': true             // we need to trigger only when 1 seconds interval passed from last iteration
}));

// ... when done
hideSpinner();

// will be debounced after 1 second interval, and if still busy - the spinner will be shown
var showSpinner = function() {
    if (isBusy) {
        $('selector').addClass('shiny-busy');
    }
}

var hideSpinner = function() {
   isBusy = false;        // our external variable is used
   if ($('selector').hasClass('shiny-busy')) {
       $('selector').removeClass('shiny-busy');
   }
}

, , , , .

+6

I'm a little confused by what I'm looking at, but overall it looks like you rely on $('html').hasClass('shiny-busy')to determine when to show it, so no matter what the brilliant busy class is, just hold it second or any other.

0
source

Source: https://habr.com/ru/post/1629576/


All Articles