You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using release 0.5.1, I initially posted this as a comment for issue #48 but decided it should be its own issue.
Issue: Float slider (step is float) fails to display float value if initial value is integer, even tho the onChange shows the correct value. It is a display problem
This (es6, babel):
var gui = new dat.GUI()
var callback = (val) => console.log('message', val, UI)
var UI = {speed: 0}
gui.add(UI, 'speed').min(-10).max(10).step(.5).onChange(callback)
.. the console shows the .5 steps but the dat.gui display only shows integer values.
This workaround shows the correct float steps, appearing to be initialized as the 0 int value:
var UI = {speed: .5}
gui.add(UI, 'speed').min(-10).max(10).step(.5).listen().onChange(callback)
UI.speed = 0
Prior comment:
This did not completely fix it for me. If I have a float slider that starts out with an integer value, I still get this problem. Works fine if the initial value is non-integer.
Does the fix here work for everyone else? I.e. float slider that starts out with integer initial value?
I did find a work-around:
Make sure the initial value is non-integer.
Add .listen() to the property.
Then set the property to the integer value.
I.e. I start with:
var UI = {
...
x: .1, // workaround for float slider bug
y: .1,
z: .1,
...
}
gui.add(UI, 'x').min(-10).max(10).step(.1).listen().onChange(callback)
gui.add(UI, 'y').min(-10).max(10).step(.1).listen().onChange(callback)
gui.add(UI, 'z').min(-10).max(10).step(.1).listen().onChange(callback)
UI.x = UI.y = UI.z = 0
The text was updated successfully, but these errors were encountered:
Using release 0.5.1, I initially posted this as a comment for issue #48 but decided it should be its own issue.
Issue: Float slider (step is float) fails to display float value if initial value is integer, even tho the onChange shows the correct value. It is a display problem
This (es6, babel):
var gui = new dat.GUI()
var callback = (val) => console.log('message', val, UI)
var UI = {speed: 0}
gui.add(UI, 'speed').min(-10).max(10).step(.5).onChange(callback)
.. the console shows the .5 steps but the dat.gui display only shows integer values.
This workaround shows the correct float steps, appearing to be initialized as the 0 int value:
var UI = {speed: .5}
gui.add(UI, 'speed').min(-10).max(10).step(.5).listen().onChange(callback)
UI.speed = 0
Prior comment:
This did not completely fix it for me. If I have a float slider that starts out with an integer value, I still get this problem. Works fine if the initial value is non-integer.
Does the fix here work for everyone else? I.e. float slider that starts out with integer initial value?
I did find a work-around:
Make sure the initial value is non-integer.
Add .listen() to the property.
Then set the property to the integer value.
I.e. I start with:
var UI = {
...
x: .1, // workaround for float slider bug
y: .1,
z: .1,
...
}
gui.add(UI, 'x').min(-10).max(10).step(.1).listen().onChange(callback)
gui.add(UI, 'y').min(-10).max(10).step(.1).listen().onChange(callback)
gui.add(UI, 'z').min(-10).max(10).step(.1).listen().onChange(callback)
UI.x = UI.y = UI.z = 0
The text was updated successfully, but these errors were encountered: