@momentum-ui/react-collaboration
Version:
Cisco Momentum UI Framework for React Collaboration Applications
15 lines • 729 B
JavaScript
import { clamp } from '@react-aria/utils';
export var getValuePercentage = function (value, min, max) {
var percentage = ((value - min) / (max - min)) * 100;
return clamp(percentage, 0, 100);
};
export var setLocalValueOnElement = function (element) {
// passing in the element values as numbers, using the unary plus operator:
var percentageValue = getValuePercentage(+element.value, +element.min, +element.max);
var existingLocalValue = element.style.getPropertyValue('--local-value');
var newLocalValue = "".concat(percentageValue, "%");
if (existingLocalValue !== newLocalValue) {
element.style.setProperty('--local-value', newLocalValue);
}
};
//# sourceMappingURL=Slider.utils.js.map