This repository was archived by the owner on Jan 13, 2025. It is now read-only.
This repository was archived by the owner on Jan 13, 2025. It is now read-only.
Implement Slider Component #25
Closed
Description
@sgomes already doing some work on this.
Notes
Step values need to be able to be quantized to decimal places, e.g. min = 0, max = 5, step = .2
. Possible algorithm: Take the raw value, divide it by step
, round that number, and then multiply the original step value by the rounded number. E.g.
function quantize(val, min, max, step) {
const numSteps = Math.round(val / step);
const quantizedVal = numSteps * step;
return Math.max(min, Math.min(max, quantizedVal));
}
const min = 0, max = 5, step = .2;
quantize(3.56, min, max, step); // 3.6
quantize(2.148692, min, max, step) // 2.2
quantize(1.061733, min, max, step) // 1
Copied from google/material-design-lite#4494