Shiny slider restrict reaction to releasing left mouse button

前端 未结 2 1865
旧巷少年郎
旧巷少年郎 2021-02-04 06:05

I am using a Shiny application in which it may take some time to set a slider to the right value.

So while trying to set the slider to the right value (and not releasing

2条回答
  •  悲&欢浪女
    2021-02-04 06:48

    Alright, after some digging, I think I've found the solution. It appears the cleanest way to do this, without needing to mess with Java script, would be to use the shinyCustom package, which has a useShinyCustom and customSliderInput function. With these, you can set the reactivity to "debounce" and also mess with the delay time. If you were to use these options together, you should be able to find the sweet spot for only updating the output once the slider stops moving. It won't be a perfect "on release of mouse button;" but it should be pretty darn close!

    For example, you may try something like:

    # Slider delay type is actually "debounce" by default 
    useShinyCustom(slider_delay = "500"), # Doubles the default delay time in ms
    customSliderInput("bins", #Use customSliderInput instead of sliderInput
                  "Number of bins:",
                  min = 1,
                  max = 50,
                  value = 30)
    

提交回复
热议问题