import { warning } from "../../../dev-warning";

const getPercentage = ({ startOfRange, endOfRange, current }) => {
  const range = endOfRange - startOfRange;
  if (range === 0) {
    warning(`
      Detected distance range of 0 in the fluid auto scroller
      This is unexpected and would cause a divide by 0 issue.
      Not allowing an auto scroll
    `);
    return 0;
  }
  const currentInRange = current - startOfRange;

  return currentInRange / range;
};

export default getPercentage;
