JuliaPluto / PlutoUI.jl

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

Slider cannot move one step at a time if the range is large #248

Open zhangcx93 opened 1 year ago

zhangcx93 commented 1 year ago

I use PlutoUI’s Slider to observe my experiment log, total length is more than 10 thousands, and want to watch the dynamics of each step one at a time. I used to use arrow keys after clicked the slider, everything was good. But right now, maybe after some version update, one click of arrow key would move the step by N, so the same for mousemove, and i cannot find any settings to make it one at a time.

How can i move one step at a time in PlutoUI’s Slider? This function is very neccessary.

This simple code can reproduce this problem. @bind test_num Slider(1:10000, show_value=true) with 10000 length, it move 10 at a time not 1.

fonsp commented 1 year ago

Hi @zhangcx93 ! That's a good question!

As a workaround, you can use @bind test_num HTML("<input type=range min=1 max=10000>") to get a classical slider that isn't affected by https://github.com/JuliaPluto/PlutoUI.jl/pull/219

zhangcx93 commented 1 year ago

@fonsp Thanks for the workaround. but it's pretty strange to me that a slider which should have few number states(like start, end, step, and currentvalue), would take much memory if the length is too large. and a downsample method is needed to fix that. did some part of the code tried to iterate or collect the range?

wilsongoode commented 1 year ago

@zhangcx93 You should be able to use the max_steps parameter for the Slider as below: @bind test_num Slider(1:10000, show_value=true, max_steps=10_000)

I think max_steps will work for arbitrarily-many steps, though you may eventually run into the performance issues that prompted the addition of that parameter.

For reference, this line in src/Builtins.jl contains a default max_steps=1_000.

@fonsp Any thoughts/preferences on how this parameter could be better communicated?