Skip to content

Commit 93a7d64

Browse files
authored
Merge branch 'main' into feature/code-editor
2 parents dce387b + d134b0b commit 93a7d64

File tree

3 files changed

+6
-40
lines changed

3 files changed

+6
-40
lines changed

src/packages/core/components/split-panel/split-panel.element.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
query,
99
state,
1010
} from '@umbraco-cms/backoffice/external/lit';
11+
import { clamp } from '@umbraco-cms/backoffice/utils';
1112

1213
/**
1314
* Custom element for a split panel with adjustable divider.
@@ -89,13 +90,9 @@ export class UmbSplitPanelElement extends LitElement {
8990
}
9091
}
9192

92-
#clamp(value: number, min: number, max: number) {
93-
return Math.min(Math.max(value, min), max);
94-
}
95-
9693
#setPosition(pos: number) {
9794
const { width } = this.mainElement.getBoundingClientRect();
98-
const localPos = this.#clamp(pos, 0, width);
95+
const localPos = clamp(pos, 0, width);
9996
const percentagePos = (localPos / width) * 100;
10097
this.position = percentagePos + '%';
10198
}
@@ -127,7 +124,7 @@ export class UmbSplitPanelElement extends LitElement {
127124
const move = (event: PointerEvent) => {
128125
const { clientX } = event;
129126
const { left, width } = this.mainElement.getBoundingClientRect();
130-
const localPos = this.#clamp(clientX - left, 0, width);
127+
const localPos = clamp(clientX - left, 0, width);
131128
const mappedPos = mapXAxisToSnap(localPos, width);
132129

133130
this.#lockedPanelWidth = this.lock === 'start' ? mappedPos : width - mappedPos;

src/packages/core/temporary-file/components/temporary-file-badge.element.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { css, customElement, html, property } from '@umbraco-cms/backoffice/external/lit';
22
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
3-
import { clamp } from '@umbraco-cms/backoffice/external/uui';
3+
import { clamp } from '@umbraco-cms/backoffice/utils';
44

55
@customElement('umb-temporary-file-badge')
66
export class UmbTemporaryFileBadgeElement extends UmbLitElement {

src/packages/core/utils/math/math.ts

Lines changed: 2 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,5 @@
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 };
343

354
/**
365
* Performs linear interpolation (lerp) between two numbers based on a blending factor.

0 commit comments

Comments
 (0)