INNER CODE UNIT · TypeScript

clampVelocity

terrysahaidak/react-native-gallery-toolkit · packages/common/src/common.ts:85

export function clampVelocity(
  velocity: number,
  minVelocity: number,
  maxVelocity: number,
) {
  'worklet';

  if (velocity > 0) {
    return Math.min(Math.max(velocity, minVelocity), maxVelocity);
  } else {
    return Math.max(Math.min(velocity, -minVelocity), -maxVelocity);
  }
}

export function runOnce(fn: Function) {
  const ref = useRef<null | true>(null);

  if (!ref.current) {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…