UNPKG

@lagrange/animator

Version:

This library helps making parallax animations on scroll. It is built with performance in mind, as it doesn't need to relayout or paint to operate.

11 lines (10 loc) 289 B
/** * Limits a number between a range of 2 numbers * @param {(string|number)} num * @param {number} min * @param {number} max */ export const constrain = (num, min, max) => { const n = typeof num === 'string' ? parseInt(num, 10) : num; return Math.min(Math.max(n, min), max); };