zalo / CascadeStudio

A Full Live-Scripted CAD Kernel in the Browser
https://zalo.github.io/CascadeStudio/
MIT License
1.01k stars 126 forks source link

Add steps and degree of precision in sliders #31

Closed UriShX closed 3 years ago

UriShX commented 3 years ago

For more precision in modelling gears, etc., I tried implementing ControlKit's steps and dp in Slider.

Had a bit of an issue with Intellisense's definitions. I did not manage to implement Integer type in ts. A possible candidate might be newtype-ts's Integer, but I don't really know how to add it to client rendered projects.

vercel[bot] commented 3 years ago

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: https://vercel.com/zalo/cascade-studio/d0nmywkhb
✅ Preview: https://cascade-studio-git-steps-in-vars.zalo.vercel.app

UriShX commented 3 years ago

Thanks for taking the time to review my PR mate.

I find the slider only moves when moving the bar with my mouse and not with my keyboard arrows (integrated laptop pc, running Linux, if that's important). "Step" does control the amount by which the slider (and thus the linked variable) increments/decrements.

I have added the following:

@param step controls the amount that the keyboard arrow keys will increment or decrement a value. Defaults to 1/100 (0.01). @param precision controls how many decimal places the slider can have (i.e. "0" is integers, "1" includes tenths, etc.). Defaults to 2 decimal places (0.00).

@examplelet currentSliderValue = Slider("Radius", 30 , 20 , 40, false); @examplelet currentSliderValue = Slider("Radius", 30 , 20 , 40, false, 0.01); @examplelet currentSliderValue = Slider("Radius", 30 , 20 , 40, false, 0.01, 2);