georgealways / lil-gui

Makes a floating panel for controllers on the web. Works as a drop-in replacement for dat.gui in most projects.
https://lil-gui.georgealways.com/
MIT License
1.15k stars 47 forks source link

Wrong step increment for number slider #141

Open vkuchinov opened 3 months ago

vkuchinov commented 3 months ago

Here is a small piece of code:

const gui = new GUI(); const params = { num: 2760 }; gui.add(params, 'num', 2200, 3000, 80);

The slider should consists of numbers starting from 2200 to 3000 with a step of 80, however it twists the sequence from its second number [2200, 2240, ... 3000], while it has to be [2200, 2280, ... 3000].

The right sequence which has to be at slider is 2200, 2280, 2360, 2440, 2520, 2600, 2680, 2760, 2840, 2920, 3000.

I have tried to set a step parameters with gui.add(params, 'num', 2200, 3000, 80).step(80); with same glitchy result.

georgealways commented 3 months ago

Hi! Thanks for reporting this. Right, I think this is because the range you're giving isn't divisible by step. But the desired behavior you're describing is very reasonable. I'll look into this.

Thanks! -g