Blinking Loading Text in R Shiny

試著忘記壹切 提交于 2019-12-04 04:43:08

问题


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?

However, I'm not sure how to implement this in R.

I have the following loading feature in my ui code:

tags$head(tags$style(type="text/css", 
                      "#loadmessage {
                       position: fixed;
                       top: 50%;
                       left: 50%;
                       ocacity: 0.50; 
                       opacity: 0.0;
                       text-align: center;
                       font-weight: bold;
                       font-size: 300%;
                       color: #000000;
                       z-index: 105;
                       }"))


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

回答1:


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)


来源:https://stackoverflow.com/questions/37470226/blinking-loading-text-in-r-shiny

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!