adwaveui
Version:
Interactive Web Components inspired by the Gtk Adwaita theme.
32 lines (30 loc) • 790 B
JavaScript
var __defProp = Object.defineProperty;
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
// src/utils/math.ts
function clamp(value, min, max) {
if (min !== void 0 && value < min) {
return min;
}
if (max !== void 0 && value > max) {
return max;
}
return value;
}
__name(clamp, "clamp");
function toPrecision(value, precision) {
const pow = 10 ** precision;
const int = Math.floor(value * pow);
return Number(int) / pow;
}
__name(toPrecision, "toPrecision");
function changeWithStep(oldValue, newValue, step) {
const diff = newValue - oldValue;
const stepCount = Math.round(diff / step);
return oldValue + stepCount * step;
}
__name(changeWithStep, "changeWithStep");
export {
changeWithStep,
clamp,
toPrecision
};