Blinking Loading Text in R Shiny

前端 未结 1 1173
夕颜
夕颜 2021-01-19 04:58

What do I add to the ui part of shiny that will make my #loadmessage blink? I\'ve seen things like this

How to make blinking/flashing text with css3?

Howe

相关标签:
1条回答
  • 2021-01-19 05:07

    Like this probably?

    library(shiny)
    
    ui <- shinyUI(
      fluidPage(
        tags$head(tags$style(type="text/css", 
          "#loadmessage {
            position: fixed;
            top: 50%;
            left: 50%;
            ocacity: 0.50; 
            text-align: center;
            font-weight: bold;
            font-size: 300%;
            color: #000000;
            z-index: 105;
            animation: blinker 1s linear infinite;
          }")),
    
        conditionalPanel(condition="$('html').hasClass('shiny-busy')",
          tags$div("Loading...",id="loadmessage"),
          tags$script(HTML("
            (function blink() { 
              $('#loadmessage').fadeOut(500).fadeIn(500, blink); 
            })();
          "))
        ),
        actionButton("action", "action")
      )
    )
    
    server <- function(input, output){
      observeEvent(input$action, {
        Sys.sleep(3)
      })
    }
    
    shinyApp(ui, server)
    
    0 讨论(0)
提交回复
热议问题