JuliaPluto / PlutoUI.jl

https://featured.plutojl.org/basic/plutoui.jl
The Unlicense
299 stars 54 forks source link

Introducing a delay on calculation of values associated to Slider #177

Closed egonik-unlp closed 2 years ago

egonik-unlp commented 2 years ago

Is it possible to make sliders somehow pass on the value once the slider stops moving? I have somewhat heavy computations downstream of the slider, and would like to be able to only make them once the slider stops moving.

thanks!

pankgeorg commented 2 years ago

Can you check if the PlutoUI.confirm function is what you need? Take a look here: https://juliapluto.github.io/sample-notebook-previews/PlutoUI.jl.html

image

egonik-unlp commented 2 years ago

It really helps! I see only two problems with that particular implementation:

  1. It's in english (the target audience are spanish speaking chemistry students)
  2. I use multiple sliders, so it seems a bit cumbersome to have to confirm every change you decide to make (perhaps something along the lines of a single PlutoUI.Button would be better)

Thanks for your answer!

icweaver commented 2 years ago

Hey all, happy new year!

  1. I think that's a great point, @egonik-unlp, and I think that would be great additional functionality to add. Happy to make this into a PR + add some docs if it looks alright to folks?
  2. @pankgeorg and the rest of the Pluto wizards have been hard at work to make this a reality! Here's a quick example from the Live docs for confirm (I just took a few liberties with the mixing and matching of markdown and html + libraries used):
using PlutoUI
using MarkdownLiteral: @mdx

@bind speeds confirm(
    PlutoUI.combine() do Child
        @mdx("""
        ### Wind speeds
        <ul>
        $([
            @mdx("<li>$(name): $(Child(name, Slider(1:100)))")
            for name in ["North", "East", "South", "West"]
        ])
        </ul>
        """)
    end
)

speeds

Screenshot from 2022-01-04 17-46-09

fonsp commented 2 years ago

Let's discuss 1. in a new issue! https://github.com/JuliaPluto/PlutoUI.jl/issues/183

fonsp commented 2 years ago

I think the best answer to the original question is a debounce, see #69 , #105 , https://lodash.com/docs/4.17.15#debounce and https://css-tricks.com/debouncing-throttling-explained-examples/ for more info

fonsp commented 2 years ago

Let's close this in favour of #69, in addition to the helpful answers above :)

egonik-unlp commented 2 years ago

Thank you all very much!