shinyBS::bsTooltip 延迟和过期

Delaying and expiring a shinyBS::bsTooltip

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

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){})

shinyBS::bsTooltip 无法正确序列化 https://github.com/ebailey78/shinyBS/blob/shinyBS3/R/Tooltips_and_Popovers.R#L129

中嵌套的 options 列表

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

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

我会建议一个解决方法 - 使用 shinyBS::addTooltip 可以正确序列化 options

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

或者直接使用Bootstrap。

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

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

问题是:延迟确实是数字,但函数 createTooltipOrPopoverOnUI (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")