chore(editor): merge clamp functions (#10577)

Closes: [BS-2625](https://linear.app/affine-design/issue/BS-2625/合并clamp函数)
This commit is contained in:
Saul-Mirone
2025-03-03 10:33:38 +00:00
parent 899a957fab
commit 4c3c953a36
16 changed files with 21 additions and 34 deletions
@@ -2,12 +2,6 @@ export function almostEqual(a: number, b: number, epsilon = 0.0001) {
return Math.abs(a - b) < epsilon;
}
export function clamp(value: number, min: number, max: number): number {
if (value < min) return min;
if (value > max) return max;
return value;
}
export function rangeWrap(n: number, min: number, max: number) {
max = max - min;
n = (n - min + max) % max;