I am working on a project where I need to calculate some scale for slider. The user can define min, max and step. You can find the code below:
var j = Math.round(cfg.max / cfg.step);
var l = (containerWidth / (j - 1));
for (var i = 0; i < j; i++) {
s.push( <span style="left: );
s.push(l * i);
s.push( px"> );
s.push(cfg.step * (i + 1));
s.push( </span> );
}
Example: min=1 max=12 step=3
Generated scale: 3 6 9 12
Slider ticks: 1 4 7 10 12
我愿知道,我如何能够制定梯度标准。