import { offset as offsetBox, withScroll } from "css-box-model";

const offsetDraggable = ({ draggable, offset, initialWindowScroll }) => {
  const client = offsetBox(draggable.client, offset);
  const page = withScroll(client, initialWindowScroll);
  const moved = {
    ...draggable,
    placeholder: {
      ...draggable.placeholder,
      client
    },
    client,
    page
  };
  return moved;
};

export default offsetDraggable;
