bound.js 228 B

12345678910
  1. export const bound = (position, min, max) => {
  2. let ret = position
  3. if (min !== undefined) {
  4. ret = Math.max(position, min)
  5. }
  6. if (max !== undefined) {
  7. ret = Math.min(ret, max)
  8. }
  9. return ret
  10. }