2016-05-26 79 views
3

我將閃光燈的ui部分添加到哪些部分,這會使我的#loadmessage閃爍?我見過這樣的事情閃爍在R中加載文本Shiny

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

回答

3

可能是這樣的?

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

你是最棒的。謝謝! – eagermathperson