( value: number, snapPoints: number[], tolerance: number )
| 36 | * Snap a value to the nearest snap point if within tolerance |
| 37 | */ |
| 38 | export 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 |
no outgoing calls
no test coverage detected
searching dependent graphs…