代码之家  ›  专栏  ›  技术社区  ›  geotheory

延迟和过期shinyBS::bTooltip

  •  3
  • geotheory  · 技术社区  · 8 年前

    是否可以延迟工具提示并在几秒钟后过期?

    require(shiny)
    require(shinyBS)
    
    shinyApp(ui = fluidPage(
      shinyjs::useShinyjs(),
      bsTooltip(id = 'input', title = "Lets delay this appearing for 1s and force disappear after 5s", 
        placement = "bottom", trigger = "hover", options = list(delay = list(show=1000, hide=3000))),
    
      sidebarLayout(
        sidebarPanel(
          selectInput(inputId = 'input', label = 'input', choices = c('cats','dogs'))
        ),
        mainPanel()
      )
    )
    , server = function(input, output){})
    

    enter image description here

    2 回复  |  直到 8 年前
        1
  •  4
  •   greg L    8 年前

    shinyBS::bsTooltip 未能正确序列化嵌套 options 中的列表 https://github.com/ebailey78/shinyBS/blob/shinyBS3/R/Tooltips_and_Popovers.R#L129

    这个 选项 对象最终看起来像 { delay: "list(show = 1000, hide = 3000)" }

    不幸的是,shinyBS似乎不再维护,或者修复程序值得提交。

    我将建议一种解决方法-使用 shinyBS::addTooltip 哪个会序列化 选项 正确地

    require(shiny)
    require(shinyBS)
    
    shinyApp(
      ui = fluidPage(
        # shinyjs::useShinyjs(),
        shinyBS:::shinyBSDep,
    
        sidebarLayout(
          sidebarPanel(
            selectInput(inputId = 'input', label = 'input', choices = c('cats','dogs'))
          ),
          mainPanel()
        )
      ),
      server = function(input, output, session) {
        addTooltip(session, id = 'input', title = "Lets delay this appearing for 1s and force disappear after 5s",
                   placement = "bottom", trigger = "hover", options = list(delay = list(show=1000, hide=3000)))
      }
    )
    

    或者直接使用引导。

        2
  •  3
  •   Lukas    7 年前

    我用过tipify。所以我的代码是这样的:

    tipify(
      element,
      title = "some title",
      options = list("delay" = 1000)
    )
    

    问题是:延迟确实是数字,但函数 CreateToolTipopoveronUI ( https://github.com/ebailey78/shinyBS/blob/shinyBS3/R/Tooltips_and_Popovers.R )将在所有参数周围放置引号:

    options = paste0("{'", paste(names(options), options, sep = "': '", collapse = "', '"), "'}")
    

    所以我这么做了:我并不为此感到骄傲,但它确实奏效了:

    options = list("delay': 1000, 'it" = "sucks")