UNPKG

@attio/react-native-bottom-sheet-toolbox

Version:
21 lines (19 loc) 633 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.snapPoint = snapPoint; /** * Snap the given value to the closest point, taking into account the velocity. */ function snapPoint(value, velocity, points, projectionScale = 0.2) { "worklet"; if (points.length === 0) { throw new Error("Must provide at least one snap-point."); } const projectedPoint = value + velocity * projectionScale; const deltas = points.map(p => Math.abs(projectedPoint - p)); const minDelta = Math.min(...deltas); return points[deltas.indexOf(minDelta)] ?? null; } //# sourceMappingURL=snap-point.js.map