|
1 |
| -/** |
2 |
| - * Clamps a value to be within a specified range defined by a minimum and maximum value. |
3 |
| - * |
4 |
| - * @param {number} value - The value to be clamped. |
5 |
| - * @param {number} min - The minimum value allowed in the range. |
6 |
| - * @param {number} max - The maximum value allowed in the range. |
7 |
| - * |
8 |
| - * @returns {number} The clamped value, which is limited to the range between `min` and `max`. |
9 |
| - * - If `value` is less than `min`, it is set to `min`. |
10 |
| - * - If `value` is greater than `max`, it is set to `max`. |
11 |
| - * - If `value` is already within the range [min, max], it remains unchanged. |
12 |
| - * |
13 |
| - * @example |
14 |
| - * // Clamp a value to ensure it falls within a specific range. |
15 |
| - * const inputValue = 15; |
16 |
| - * const minValue = 10; |
17 |
| - * const maxValue = 20; |
18 |
| - * const result = clamp(inputValue, minValue, maxValue); |
19 |
| - * // result is 15, as it falls within the range [minValue, maxValue]. |
20 |
| - * |
21 |
| - * // Clamp a value that is outside the specified range. |
22 |
| - * const outsideValue = 5; |
23 |
| - * const result2 = clamp(outsideValue, minValue, maxValue); |
24 |
| - * // result2 is 10, as it's clamped to the minimum value (minValue). |
25 |
| - * |
26 |
| - * // Clamp a value that exceeds the maximum limit. |
27 |
| - * const exceedingValue = 25; |
28 |
| - * const result3 = clamp(exceedingValue, minValue, maxValue); |
29 |
| - * // result3 is 20, as it's clamped to the maximum value (maxValue). |
30 |
| - */ |
31 |
| -export function clamp(value: number, min: number, max: number): number { |
32 |
| - return Math.min(Math.max(value, min), max); |
33 |
| -} |
| 1 | +import { clamp } from '@umbraco-cms/backoffice/external/uui'; |
| 2 | +export { clamp }; |
34 | 3 |
|
35 | 4 | /**
|
36 | 5 | * Performs linear interpolation (lerp) between two numbers based on a blending factor.
|
|
0 commit comments