3

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

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

在此处输入图像描述

4

2 回答 2

4

shinyBS::bsTooltip无法正确序列化https://github.com/ebailey78/shinyBS/blob/shinyBS3/R/Tooltips_and_Popovers.R#L129options中的嵌套列表

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。

于 2017-11-24T18:41:47.233 回答
2

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

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

问题是:延迟确实是数字的,但函数createTooltipOrPopoverOnUIhttps://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")
于 2019-01-14T17:48:36.547 回答