|
8 | 8 | query,
|
9 | 9 | state,
|
10 | 10 | } from '@umbraco-cms/backoffice/external/lit';
|
| 11 | +import { clamp } from '@umbraco-cms/backoffice/utils'; |
11 | 12 |
|
12 | 13 | /**
|
13 | 14 | * Custom element for a split panel with adjustable divider.
|
@@ -89,13 +90,9 @@ export class UmbSplitPanelElement extends LitElement {
|
89 | 90 | }
|
90 | 91 | }
|
91 | 92 |
|
92 |
| - #clamp(value: number, min: number, max: number) { |
93 |
| - return Math.min(Math.max(value, min), max); |
94 |
| - } |
95 |
| - |
96 | 93 | #setPosition(pos: number) {
|
97 | 94 | const { width } = this.mainElement.getBoundingClientRect();
|
98 |
| - const localPos = this.#clamp(pos, 0, width); |
| 95 | + const localPos = clamp(pos, 0, width); |
99 | 96 | const percentagePos = (localPos / width) * 100;
|
100 | 97 | this.position = percentagePos + '%';
|
101 | 98 | }
|
@@ -127,7 +124,7 @@ export class UmbSplitPanelElement extends LitElement {
|
127 | 124 | const move = (event: PointerEvent) => {
|
128 | 125 | const { clientX } = event;
|
129 | 126 | const { left, width } = this.mainElement.getBoundingClientRect();
|
130 |
| - const localPos = this.#clamp(clientX - left, 0, width); |
| 127 | + const localPos = clamp(clientX - left, 0, width); |
131 | 128 | const mappedPos = mapXAxisToSnap(localPos, width);
|
132 | 129 |
|
133 | 130 | this.#lockedPanelWidth = this.lock === 'start' ? mappedPos : width - mappedPos;
|
|
0 commit comments