import { negate, subtract } from "../../position";
import { offsetByPosition } from "../../spacing";
import didStartAfterCritical from "../../did-start-after-critical";

export const getCurrentPageBorderBoxCenter = (draggable, afterCritical) => {
  // If an item started displaced it is now resting
  // in a non-displaced location
  const original = draggable.page.borderBox.center;
  return didStartAfterCritical(draggable.descriptor.id, afterCritical)
    ? subtract(original, afterCritical.displacedBy.point)
    : original;
};
export const getCurrentPageBorderBox = (draggable, afterCritical) => {
  // If an item started displaced it is now resting
  // in a non-displaced location
  const original = draggable.page.borderBox;
  return didStartAfterCritical(draggable.descriptor.id, afterCritical)
    ? offsetByPosition(original, negate(afterCritical.displacedBy.point))
    : original;
};
