Utilities

👈 React UseGesture uses a set of utility functions internally that are exposed for anybody's convenience.

addV

Adds two vectors.

import { addV } from 'react-use-gesture'
addV([10, 5], [5, 7]) // returns [15, 12]

subV

Substracts two vectors.

import { subV } from 'react-use-gesture'
subV([10, 5], [1, 2]) // returns [9, 3]

rubberbandIfOutOfBounds

Calculates the rubberbanding effect from a given position value, two bounds min, max and an elasticity constant.

function rubberbandIfOutOfBounds(position: number, min: number, max: number, constant = 0.15): number