Skip to content

Commit 6ed9c35

Browse files
committed
Actual int sliders
1 parent 4427c04 commit 6ed9c35

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/immediate-ui.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ function SliderControlCreate(
1414
name: string,
1515
value: string,
1616
lo: string,
17-
hi: string
17+
hi: string,
18+
is_int: boolean
1819
): HTMLElement {
1920
const el = document.createElement("control")
2021

@@ -27,7 +28,7 @@ function SliderControlCreate(
2728
inputEl.setAttribute("type", "range")
2829
inputEl.setAttribute("min", lo)
2930
inputEl.setAttribute("max", hi)
30-
const step = 0.001
31+
const step = is_int ? 1.0 : 0.001
3132
inputEl.setAttribute("step", step + "")
3233
inputEl.setAttribute("value", value)
3334
// TODO: compute this based on slider width
@@ -71,7 +72,7 @@ export class UIState{
7172
floatSlider(name: string, prevValue: number, lo: number, hi: number) : number {
7273
const control = this.control("float", name)
7374
if (!control.el) {
74-
control.el = SliderControlCreate(name, prevValue + "", lo + "", hi + "")
75+
control.el = SliderControlCreate(name, prevValue + "", lo + "", hi + "", false)
7576
this.controlsEl.append(control.el)
7677
}
7778

@@ -87,7 +88,7 @@ export class UIState{
8788
intSlider(name: string, prevValue: number, lo: number, hi: number) : number {
8889
const control = this.control("float", name)
8990
if (!control.el) {
90-
control.el = SliderControlCreate(name, prevValue + "", lo + "", hi + "")
91+
control.el = SliderControlCreate(name, prevValue + "", lo + "", hi + "", true)
9192
this.controlsEl.append(control.el)
9293
}
9394

0 commit comments

Comments
 (0)