我应该在 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/