MCPcopy
hub / github.com/tomkp/react-split-pane / snapToPoint

Function snapToPoint

src/utils/calculations.ts:38–49  ·  view source on GitHub ↗
(
  value: number,
  snapPoints: number[],
  tolerance: number
)

Source from the content-addressed store, hash-verified

36 * Snap a value to the nearest snap point if within tolerance
37 */
38export function snapToPoint(
39 value: number,
40 snapPoints: number[],
41 tolerance: number
42): number {
43 for (const point of snapPoints) {
44 if (Math.abs(value - point) <= tolerance) {
45 return point;
46 }
47 }
48 return value;
49}
50
51/**
52 * Distribute sizes proportionally when container size changes

Callers 2

useResizerFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…