css - 在 R Shiny 中闪烁加载文本

标签 css r shiny loading

我应该在 shiny 的 ui 部分添加什么,让我的#loadmessage 闪烁?我见过这样的事情

How to make blinking/flashing text with css3?

但是,我不确定如何在 R 中实现它。

我的 ui 代码中有以下加载功能:

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"))

最佳答案

大概是这样?

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)

关于css - 在 R Shiny 中闪烁加载文本,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37470226/

相关文章:

css - Magento - 如何将页脚设置为 100% 宽度?

asp.net - 使用来自 thems 目录的 css 文件更改 css 指令?

r - 根据值微移 ggplot 文本

r - 更安全的purrr::map2用于名称乱序的列表

r - 在循环中运行箱形图/水平线时,hline 索引没有改变的问题

r - 如何用 shinyjs 隐藏 navbarMenus?

r - 单击 Leaflet map 上的点以在 Shiny 中生成 ggplot

javascript - css 未加载,因为它在 Meteor JS 中的 MIME 类型

javascript - iOS Safari 忽略 javascript 中的溢出隐藏代码

r - 更改输入值时不要删除无功变量(用户输入的)值