zent
Version:
一套前端设计语言和基于React的实现
20 lines (19 loc) • 566 B
JavaScript
export var getLeft = function (value, min, max) {
return ((value - min) * 100) / (max - min);
};
export var getValue = function (ratio, min, max) {
return min + (max - min) * ratio;
};
export var toFixed = function (value, fractionDigits) {
return Number(value.toFixed(fractionDigits));
};
export function isLeftValue(nextValue, value) {
if (nextValue > value[1]) {
return false;
}
if (nextValue <= value[0] ||
Math.abs(value[0] - nextValue) <= Math.abs(value[1] - nextValue)) {
return true;
}
return false;
}