import { bound } from "./bound";
function rubberband(distance, dimension, constant) {
  return distance * dimension * constant / (dimension + constant * distance);
}
function rubberbandIfOutOfBounds(position, min, max, dimension, constant = 0.15) {
  if (constant === 0)
    return bound(position, min, max);
  if (position < min)
    return -rubberband(min - position, dimension, constant) + min;
  if (position > max)
    return +rubberband(position - max, dimension, constant) + max;
  return position;
}
export {
  rubberband,
  rubberbandIfOutOfBounds
};
