import getScroll from "./get-scroll";
import { canScrollDroppable } from "../can-scroll";

const getDroppableScrollChange = ({ droppable, subject, center, dragStartTime, shouldUseTimeDampening }) => {
  // We know this has a closestScrollable
  const frame = droppable.frame;

  // this should never happen - just being safe
  if (!frame) {
    return null;
  }
  const scroll = getScroll({
    dragStartTime,
    container: frame.pageMarginBox,
    subject,
    center,
    shouldUseTimeDampening
  });
  return scroll && canScrollDroppable(droppable, scroll) ? scroll : null;
};

export default getDroppableScrollChange;
